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

Csv file with varying number of columns in each row

heidi_andrew
Contributor

my csv file has several rows for each person on the file. The specific rows have different number of columns in each row. CSV file reader is having trouble with it. Is this impossible to read for this snap?

1 ACCEPTED SOLUTION

koryknick
Employee
Employee

@heidi.andrew - here is another pipeline that provides a couple more examples how this could be done. In this pipeline, there are two examples - the first is similar to what @alchemiz has done, but with an added step to simplify the syntax of the record conversion into an array then object. The second path steps it down even farther using all basic snap functionality to split the input stream so it can be parsed separately based on the input row type.

I hope this helps!
Community 15513 - Multi-row CSV_2023_02_22.slp (24.3 KB)

View solution in original post

17 REPLIES 17

darshthakkar
Valued Contributor

Hi @heidi.andrew,

I havenโ€™t seen this issue thus far with File reader snap. Can you please elaborate the snaps youโ€™re using for this?
Usually, I would go ahead with File Reader โ†’ CSV Parser โ†’ Mapper (with null-safe access checked on)
If youโ€™re using the same snaps, can you share the settings youโ€™re using for File Reader and CSV parser?

heidi_andrew
Contributor

image

image
Here are a couple of people and their rows:
EEID|55555|xxxxxxxxx|MICHAEL|C|xxxxx|M|06/21/xxxx
OFFR|55555|01/01/2023-55|OE|01/01/2023|01/01/2023|01/01/2023|12/31/2023|02/06/2023 05:00:00.000000 AM
ELIG|55555|01/01/2023-55|CDHU02500L|BLUE BASIC|EEONLY|EMPLOYEE ONLY|Y|103.28|511.62|Y|Y|Y|Y|Y|||
COVG|55555|OE|01/01/2023|||||||01/01/2023|||||Y|06|UNKNOWN|02/06/2023 05:00:00.000000 AM|01/01/2023-55
EEID|7777777|xxxxxxxxx|KEITH|E|xxxxxxxx|M|11/11/xxxx
OFFR|7777777|xxxxxxxxx|KEITH|E|xxxxxxxx|M|11/11/xxxx
OFFR|7777777|01/01/2023-55|OE|01/01/2023|01/01/2023|01/01/2023|12/31/2023|02/06/2023 05:00:00.000000 AM
ELIG|7777777|01/01/2023-55|CDHU02500L|BLUE BASIC|EEONLY|EMPLOYEE ONLY|Y|203.28|411.62|Y|Y|Y|Y|Y|||
COVG|7777777|OE|01/01/2023|||||||01/01/2023|||||Y|06|UNKNOWN|02/06/2023 05:00:00.000000 AM|01/01/2023-55

heidi_andrew
Contributor

I also played around with the ignore empty data and surrounding spaces features but that did not work for me either. there are no headings in the file but i gave it header names and thought that may help. i am joining them with another file. that does not give errors yet as i have been unable to get past that csv file reader.
image

Hi @heidi.andrew,

Can you please share a sample .csv file if you donโ€™t mind. The snap properties look good to me however I might be overlooking something so wanted to try it on my end.

If itโ€™s a sensitive data, you can truncate and share me a reduced version of the file.
Thanks.

Regards,
Darsh