Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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
I think this code will replace all double quotes, bc want to keep the double quotes around "A".
Hi
With CSV option, you have to contain escape char in source file. eg:
"XCFDGHJ\"A\"updated"
Regards
Shong
Thanks for your answer!
While using row7.content.replaceAll("\\"","") getting error "String literal is not properly closed by a double-quote"
my fault :
row7.content.replaceAll("\"","")
it will replace all the double quote of the document
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 "
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.
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