cancel
Showing results for 
Search instead for 
Did you mean: 

How to use CSV Parser to read multiple records in single row

aanchalrajpal
New Contributor

Hi,

I have a csv file ‘|’ separated which has records like below.

123456|61|eng |01|aabc|test|16|Long|,|01|aabc|test1|Regular|Short||
112569|61|eng |01|vfbc|test3|16|XL|

how to read both records as 1st record has 2 details in a single row separated by comma. CSV parser is giving below error-

“The CSV record has more columns than data, Resolution: Please provide valid CSV data at line 7 or route it to the error view”

please suggest

6 REPLIES 6

I want my pipeline to read both the records as that is how i will get my csv file.Yes their can be blank line character in file. But my concern here is m not able to read both the records as csv parser takes first line and set no of columns but when it comes to next row the columns get decreased and it failed. So is their any way we can read both the rows by any snap.

You’re most likely going to need to use a Script snap. The CSV parser (as I understand it), expects an exact number of columns per every record.

Presuming (yet without knowing) the data definition of your input, you might potentially use Naveen’s option combined with a Mapper snap and Expression Language to pad the right-hand side record with pipes to resize all delimited records with the same number of delimeters. Otherwise, use script to parse and create the exact output that you need.