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

Using strict and skipLines together causes Uncaught TypeError #136

Closed
RimashMohomed opened this issue Jul 13, 2019 · 0 comments
Closed

Using strict and skipLines together causes Uncaught TypeError #136

RimashMohomed opened this issue Jul 13, 2019 · 0 comments

Comments

@RimashMohomed
Copy link

RimashMohomed commented Jul 13, 2019

  • Operating System:Ubuntu 18.04.1 LTS (Bionic Beaver)
  • Node Version:v8.10.0
  • NPM Version:6.10.0
  • csv-parser Version:v2.0

Expected Behavior

Given strict option is set to true and skipLines is set to 2
When skipped rows are parsed and skipped rows are validated for strict option
Then Uncaught TypeError: Cannot read property 'length' of null is return

Actual Behavior

Given strict option is set to true and skipLines is set to 2
When skipped rows are parsed
Then skipped rows should not be validated for strict option

How Do We Reproduce?

Pass in header option, {strict: true, skipLines: 2},
and use file contents:

Valuea0,Valueb0,Valuec0
Valuea1,Valueb1,Valuec1
Headera2,Headerb2,Headerc2
Valuea3,Valueb3,Valuec3
Valuea4,Valueb4,Valuec4

then result would be

Uncaught TypeError: Cannot read property 'length' of null at CsvParser._online (/home/rimash/Work/Excube/excubed/node_modules/csv-parser/index.js:202:54) at CsvParser._transform (/home/rimash/Work/Excube/excubed/node_modules/csv-parser/index.js:263:16) at CsvParser.Transform._read (_stream_transform.js:186:10) at CsvParser.Transform._write (_stream_transform.js:174:12) at doWrite (_stream_writable.js:397:12) at writeOrBuffer (_stream_writable.js:383:5) at CsvParser.Writable.write (_stream_writable.js:290:11) at ReadStream.ondata (_stream_readable.js:639:20) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at ReadStream.Readable.push (_stream_readable.js:208:10) at fs.read (fs.js:2051:12) at FSReqWrap.wrapper [as oncomplete] (fs.js:658:17)

but it should be

[{ 'Headera2': 'Valuea3', 'Headerb2': 'Valueb3', 'Headerc2': 'Valuec3' },
{ 'Headera2': 'Valuea4', 'Headerb2': 'Valueb4', 'Headerc2': 'Valuec4' }]

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

No branches or pull requests

2 participants