cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Split string into rows and save it to file row by row, not in one string

SL12345
New Contributor III

Lets say i have this input string in my mapper:

"Mercedes;6658;TypeS;2022;\r\nAudi;5558;TypeA8;2022;Diesel"

How can i save it to csv file as single rows? in this example it should be:

Mercedes;6658;TypeS;2022;
Audi;5558;TypeA8;2022;Diesel

I've tried myString.split('\r\n') it creates two strings which i can not export/save as file because its list, or these strings were comma separated and stored as one line in export file

Thank you for your help

1 ACCEPTED SOLUTION

Try with this one.

View solution in original post

6 REPLIES 6

Hi Alexandar, curious,  if scenatio below is possible to do in snaplogic: 

Scenario  first row has fixed length 10 fields

"Audi";"5558";"TypeA8";"2022";"Diesel";"";test1;"";"";"Germany";

Second row has  5

"Mercedes";"";"TypeS";"2022";"India";

there can be empty space in both in first row and in second row as well. Is it possible instead of this: 

"Audi";"5558";"TypeA8";"2022";"Diesel";"";test1;"";"";"Germany";
"Mercedes";"";"TypeS";"2022";"India";"";"";"";"";"";

 

get this? (get rid of empty fields(from field 6  to field 10)

"Audi";"5558";"TypeA8";"2022";"Diesel";"";test1;"";"";"Germany";
"Mercedes";"";"TypeS";"2022";"India";

 

thank you

 

Hello @SL12345,

Could you please try with the following sample pipeline?

In the Map - Fields Snap expression we have a filter that filters out the empty values.

Let me know if this helps you.

Regards,

Aleksandar.