Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on('headers') not showing "0" as headers but in on('data') without headers values are shown with "0" headers #209

Closed
sharmapr25 opened this issue Dec 16, 2021 · 1 comment

Comments

@sharmapr25
Copy link

  • Operating System: macOs Big Sur
  • Node Version: v8.17.0
  • NPM Version: 6.13.4
  • csv-parser Version: ^2.3.0

Csv sample

name
Niru
Sangam
Gopal,
Mansa

Expected Behavior

There is a comma(,) after Gopal in sample csv that will get consider as different header except name. According to logic it will place it under "0" header. For .on('headers') event it should return all headers with '0' also Or it should throw invalid csv file error.

Actual Behavior

There is a comma(,) after Gopal in sample csv.
on headers event it is giving only name as header but on data event it is giving row of Gopal and Mansa with "0" header.

How Do We Reproduce?

 fs.createReadStream(file.path, 'utf8')
  .pipe(csv())
.on('headers', headers => {
   console.log('headers are ', headers) 
  })
.on('data', (row) => {
  console.log('row are: ', row)  
 }

OUTPUT

headers are [name]
row are: {"name": "Niru"}
row are: {"name": "Sangam"}
row are: {"0": "Gopal"}
row are: {"0": "Mansa"}
@sharmapr25
Copy link
Author

This issue is fixed in latest version 3.0.0. fix: losing all headers after a broken line
But now will add External logic to keep it working with node v8.17.0(as support for node 8 is not there with new version)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant