Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Replacing every even occurences of comma with pipe

Hi,

 

I have requirement to replace every even occurrences of comma with pipe-

from "a","b","c","d" to "a","b"|"c","d"

from "a","b","c","d","e","f" to "a","b"|"c","d"|"e","f"

How can I achieve the above in talend. 

Labels (2)
1 Reply
Anonymous
Not applicable
Author

I assume your data is in a flat file. So first you need to read it in. For this I would use the tFileInputFullRow. Then in a tMap (or tJavaFlex, tJavaRow), you can use code like this....

row1.line.replace(',','|')

.... to replace the values. In the tMap the code above would just be put in the output column, for a the Java components you will need to assign that value to an output column with code.

 

Alternatively (assuming you are wanting to process the data), read the data in with a tFileInputDelimited using a comma as separator, process it and output it with a tFileOutputDelimited using a pipe as a separator.