Thursday
Hello,
Below is the requirement where I have to read and parse a CSV file and load each line based on the first column's name. The file will have thousands and thousands of lines.
I have the sample csv file below and 1st line will be Header and will have 7 columns and the main body will have 13 columns and there will be trailer line at the end and that will have 3 columns.
"HEADER","20250219","053545","108","GRN","AX","4.01"
"SUMMARY","101","","A19","220","USD","19"," 3868","3868"," 102"," 1","0"," P"
"SUBMISSION","101","","A19","220","USD","124","217","217","170126","USD","0500167400","00000010"
"TRANSACTN","102","","A19","220","USD","124","217","217","170126","USD","0500167400","00000010"
"TXNPRICING","103","","A19","220","USD","124","217","217","170126","USD","0500167400","00000010"
"TRAILER","0000000108","0000058371"
I have to parse the above csv file and load each line into separate table based on the name of the first column.
For example if the first column is "HEADER", the line has to be parsed and based on each comma separated value, it has to be loaded into Header table.
If the fist column is "SUMMARY", then the each comma separated value of that line has to be parased and loaded into Summary table.
I am trying the CSV parser but getting the error as below
"Reason: The number of CSV data fields is greater than the number of header columns in the input data: number of CSV data fields = 19, number of header columns = 7, Resolution: Please make sure the number of CSV data fields is not greater than the number of header columns."
How to parse this and what would be the best way to achieve this? Thanks in advance.
Thanks
Aravind N
yesterday
Check the Header size error policy configuration within the CSV Parser Snap:
With Trim record to fit header you should be able to parse the CSV data.
yesterday
@SpiroTaleski , There are 2 things I wanted to update, the CSV doesnt have fixed length or fixed number of columns and each type (eg: Heasder, Summary, Submission) will have different number of columns and I dont want to trim the number of column, but parse each line even though there will different number of columns in each line.