Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
bc3
Contributor
Contributor

How to get the double quotes from the description field, which was in double quote text enclosure

Hi All,

I've a file which was pipe | delimiter and text are enclosed with the double quotes. One of my incoming field has double quotes in data (For Example "XCFDGHJ "A" updated") . The expected output for me was

XCFDGHJ "A" updated

But in Talend I was getting as XCFDGHJ

Can you please help me on how to

achieve this requirement.

 

I can't disable the csv option in tFileInputDelimiter as I might get | pipeline also in the description field.

Labels (2)
8 Replies
gjeremy1617088143

Hi , if pipe is a field delimiter you can clean your file before :

Read it with a fileInputRaw as a unique string

then in a t javarow or a tmap : (your string).replaceAll("\\"","")

then you write it in a fileoutputRaw

finally you can read the cleansed file.

Send me Love and Kudos

Anonymous
Not applicable

I think this code will replace all double quotes, bc want to keep the double quotes around "A".

Anonymous
Not applicable

Hi

With CSV option, you have to contain escape char in source file. eg:

"XCFDGHJ\"A\"updated"

 

Regards

Shong

bc3
Contributor
Contributor
Author

Thanks for your answer!

While using row7.content.replaceAll("\\"","") getting error "String literal is not properly closed by a double-quote"

gjeremy1617088143

my fault :

row7.content.replaceAll("\"","")

it will replace all the double quote of the document

gjeremy1617088143

StringUtils.replaceAll((your string),"(?<!\\|)\"(?!\\|)","\\\\\"") will replace all double quote not precedeed by | and not folowed by | with \"

it will work if the first and last field of your row are not enclosed with "

bc3
Contributor
Contributor
Author

Thank you.

But I can't predict the escape char for each row as it was description field, difficult to get the desired format. Is there any generic format in escape character that will not consider an double quoted data within the enclosed text.

gjeremy1617088143

 

But I can't predict the escape char for each row as it was description field,:

In fact you can predict it :

StringUtils.replaceAll((your string),"(?<!\\||^)\"(?!(\\||$))","\\\\\"")

will work for every double quote inside a field enclosed by double quote