mafintosh / csv-parser

Streaming csv parser inspired by binary-csv that aims to be faster than everyone else
MIT License
1.41k stars 134 forks source link

Column headers with the non unique names are replacing each other #218

Open sjorsjes opened 1 year ago

sjorsjes commented 1 year ago

Expected Behavior

const csv = 'type,part,part\nunicorn,horn,eye\nrainbow,pink,tail';

console.log(await neatCsv(csv)); // [{type: 'unicorn', part: 'horn', part_1: 'eye'}, {type: 'rainbow', part: 'pink', part: 'tail'}]

When importing a CSV file with non unique header names into Excel it will add _#. In this example it will create the following headers: type | part | part_1

Actual Behavior

const csv = 'type,part,part\nunicorn,horn,eye\nrainbow,pink,tail';

console.log(await neatCsv(csv)); // [{type: 'unicorn', part: 'eye'}, {type: 'rainbow', part: 'tail'}]

It looks like it overrides the previous column with the same header name.

How Do We Reproduce?

Use the examples from above or see this sandbox https://codesandbox.io/s/read-file-node-ejs-forked-pqmqrm?file=/src/index.js