One Star

tFileInputDelimted : fields enclosd in double quotes W pipe delimiter

Hello,
I have a csv file with all fields enclosed in double quotes and a pipe ('|') seperating the fields.
Ex:
"1001"|"234"|"0011"|"W2"|"1001-234"|"Textual field info"|"85"|"W2"|"0011"|"Smith, Joe"
I am trying to use this file and have it strip the double quotes from the fields when using it.
I have tried setting the CSV options with 'Text Enclosure' set to """ , and without it, and none strip them out.
Any suggestions?
thanks.
7 REPLIES
Community Manager

Re: tFileInputDelimted : fields enclosd in double quotes W pipe delimiter

Hello
You need aslo set the escape char "\"".
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tFileInputDelimted : fields enclosd in double quotes W pipe delimiter

It turns out that I need to set 'Text Enclosure' to ' "\"" ' and not ' """ " as you would expect.
If my fields are already enclosed in double quotes, what is the difference in usage or definition of
' """ '
and
' "\"" '
?
Thanks.

Re: tFileInputDelimted : fields enclosd in double quotes W pipe delimiter

the backslash tells java to interpret the next character *literally* not as a part of the program. since double quotes are used to delimit strings in java programs, you need to backslash them when you want to refer to the double quote itself.
One Star

Re: tFileInputDelimted : fields enclosd in double quotes W pipe delimiter

Since my project that I have created in Talend is java, I have to select the ' "\"" ' version,
but if it was in Perl, I would choose ' """ ' version...for the same file?
Community Manager

Re: tFileInputDelimted : fields enclosd in double quotes W pipe delimiter

Hello
In perl project, set
escape char '"'
text enclosure '"'
Bes regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tFileInputDelimted : fields enclosd in double quotes W pipe delimiter

So for the same file, I have to know how the language I select functions and handles quotes to know which escaping and enclosing method to chose?
Usability wise, it would make more sense to have the application handle that behind the scenes and allow me to just choose the actual enclosure and escape string rather than to know what is going to happen within the code.
So the choices should be just ' " ' or ' \" '
hope that makes sense.
thanks.
One Star

Re: tFileInputDelimted : fields enclosd in double quotes W pipe delimiter

\ worked for me as suggested by Shong in #2
Cheers !
Bharat