node-csv icon indicating copy to clipboard operation
node-csv copied to clipboard

CSV Parsing fail when extra cell with no column

Open MatteoGauthier opened this issue 2 years ago • 1 comments

Describe the bug

I'm trying to parse an ugly csv file, I got extra values on some records, here is an example :

Line 2 is failing because there is an extra value in this record. Expected 2 got 3

"name","address"
"Bihl Christian","16","Rue De Kingersheim 68270 Wittenheim France"
"Levy Guilene","1 Rue D Ottmarsheim 68170 Rixheim France"
{
    "code": "CSV_RECORD_INCONSISTENT_COLUMNS",
    "message": "Invalid Record Length: columns length is 2, got 3 on line 200"
}

To Reproduce

parse(csv, {
      columns: true,
      delimiter: [","],
    })

How can I clean ugly CSV file and success to parse this CSV by removing ugly data.

MatteoGauthier avatar Nov 20 '23 16:11 MatteoGauthier

Have you tried the relax_column_count option?

wdavidw avatar Nov 20 '23 18:11 wdavidw