Split string into new lines

Hello,

I am looking for a way to split a column by comma ( like string newText= split($in.0.myText, ‘,’):wink: and create a new line for each element.

Any help much appreciated!

This seems like a job for the Normalizer component.

Can you give some more information about your requirements? A short example would be helpful.

Hi,
In case you don’t insist on splitting the text into an array, you can simply replace the comma with a “\r\n” or any other line separator suitable for your operating system (e.g. \r\n for Windows, \r MacOS or \n for Linux). In a Reformat component it would then look as follows :

$out.0.Field1=replace($in.0.myText,",","\r\n");

This will result in removing the comma and adding a line separator instead of it. In Clover, you will see for example “somerandomtext” in Data Inspector in the given field, but if you open your output data in a system text editor, you will see:
some
random
text

Accordingly, you can add a line separator as a string at the end of each array element or you can work with it in multiple other ways using String Functions in CTL. But please be aware that if you use the same line separator as a metadata field delimiter, it might cause some confusions in data.

The appropriate solution for your issue depends on the exact use case, therefore I would also like to bring to your attention a component called Normalizer. This component creates one or more output records from each single input record. It means that you can use this component to split your text into multiple record lines and process them independently. For more information, please follow the link above or you can review example graph in Basic Examples called ParsingTextData.grf (in CloverETL Designer).

I hope this helps, but please let me know if I have misunderstood your question.

Thanks Eva