Split string into new lines

Support/help with CloverETL implementation problems

Withgor
Posts: 1
Joined: Sat Sep 02, 2017 9:49 am

Split string into new lines

Postby Withgor » Sat Sep 02, 2017 9:54 am

Hello,

I am looking for a way to split a column by comma ( like string[] newText= split($in.0.myText, ',');) and create a new line for each element.

Any help much appreciated!

Paulhbartosik
Posts: 1
Joined: Wed Sep 06, 2017 4:14 pm

Re: Split string into new lines

Postby Paulhbartosik » Wed Sep 06, 2017 4:26 pm

This seems like a job for the Normalizer component.

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

jandikovae
Posts: 27
Joined: Fri Nov 04, 2016 8:51 am

Re: Split string into new lines

Postby jandikovae » Thu Sep 07, 2017 8:38 am

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 :

Code: Select all

$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
---
Eva Jandikova
CloverCARE Support
CloverETL | Rapid Data Integration

Visit us online at http://www.cloveretl.com
How to speed up communication with CloverCARE support


cron