Splitting csv file into rows and then check if specified value has 10 elements

Hi snaplogic experts,

how can i split csv file into rows and then check if value after 8th semicolon has 10 values?


lets say i have values mentioned above, i can split file into rows ($content.split(‘\n’)) but how can i check in second step if after 8th semicolon there is 10 values? (values are separated with comma)

1st row will be true, 2nd row is false (because only 7 values) and 3rd will be true as well

thank you

Hi @SL12345,

If you want to do this with expression then try this:
$content.split("\n").map(row => {row: row, lengthValuse:row.split(';')[8].split(',').length })


Viktor N.


Thank you Viktor … and is there any way how to do it if i have input as a string ?


Hi @SL12345,

In the sample expression that I was writing, I was working on the sample with input as a string. Below is the sample that I was using.

        "content": "1;2566;28.3.2023;28.3.2023;10;10;15;11;1,2,3,4,5,6,7,8,9,10;Eur;Euro;USD\n2;2567;28.3.2023;28.3.2023;10;10;15;11;1,2,3,4,5,6,7;Eur;Euro;USD\n3;2566;28.3.2023;28.3.2023;10;10;15;11;1,2,3,4,5,6,7,8,9,10;Eur;Euro;USD"

For the expression to work, is expected the ‘content’ field on the input of the mapper with the CSV data inside as a string.

Viktor N.