[resolved] Character problem on a .csv file.

One Star

[resolved] Character problem on a .csv file.

Hi all,
i have a .csv file. It has two fields and fields are separated with a comma(,) character. I have to remove-replace some characters as mentioned below ;
\0 (backlslash + zero) means NULL value ( means , there should be no character)
0 (zero) means true value of zero digit ( means , do nothing)
\, (backslash + comma) means true value of comma character (means remove backslash)
\ (backslash) means true value of backslash character ( means, do nothing)
, (comma) means a fiels separator
\\ (backslash + backslash) means true values of two backslash characters (means, do nothing)
\,, (backslash + comma + comma) means true value of comma following with field separator.

i have triend to use java replace command in tMap i could not do them correctly, what is the simple way to do them all?
Thanks
Best Regards
Bahadir.

Accepted Solutions
Community Manager

Re: [resolved] Character problem on a .csv file.

Hello
Use a tFileInputFullRow to read the file line by line, and then do a replace processing on tMap, finally, output the rows to a new csv file.
row1.line.replaceAll("\\\\0", "").replaceAll("\\\\,", ",")

Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

All Replies
Community Manager

Re: [resolved] Character problem on a .csv file.

Hello
Can you give us an example and what are your expected result?
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Character problem on a .csv file.

for example, the .csv file is like this;
"Zoologiska artiklar - Tillverkare Grossister\,",Limex AB Zoologisk handel,Trojs List Zoologisk handel,Norrköpings\0 Akvarier AB Zoologisk handel,ZOOPUNKTEN.SE / Skeneciklidhobby Zoologisk handel,Ulliz Zoo Zoologisk handel,AkvarieCenter\ Zoologisk handel\,,Akvariekällaren \\Zoologisk handel,DjurMagazinet Zoologisk handel,Akvariebutiken Strömstad Zoologisk handel,Mölnlycke Djur0
the .csv file that after i work on it must be like this one;
"Zoologiska artiklar - Tillverkare Grossister,",Limex AB Zoologisk handel,Trojs List Zoologisk handel,Norrköpings Akvarier AB Zoologisk handel,ZOOPUNKTEN.SE / Skeneciklidhobby Zoologisk handel,Ulliz Zoo Zoologisk handel,AkvarieCenter\ Zoologisk handel,,Akvariekällaren \\Zoologisk handel,DjurMagazinet Zoologisk handel,Akvariebutiken Strömstad Zoologisk handel,Mölnlycke Djur0
Community Manager

Re: [resolved] Character problem on a .csv file.

Hello
Use a tFileInputFullRow to read the file line by line, and then do a replace processing on tMap, finally, output the rows to a new csv file.
row1.line.replaceAll("\\\\0", "").replaceAll("\\\\,", ",")

Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Character problem on a .csv file.

hi,
it works great, thank you Shong.
Best Regars
Bahadir