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
Only skip first n lines in the first chunk and don't take the first line as header (#1045) #1046
base: master
Are you sure you want to change the base?
Conversation
@@ -1585,11 +1585,11 @@ var PARSE_TESTS = [ | |||
} | |||
}, | |||
{ | |||
description: "Skip First N number of lines , with header and 3 rows", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not remove existing test suite but add a new test latter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did'nt remove the test, I corrected it.
As I already mentioned, the first line should be expected to be the header row in the result. (because it should be skipped with skipFirstNLines=1
papaparse.js
Outdated
@@ -511,6 +511,11 @@ License: MIT | |||
this.parseChunk = function(chunk, isFakeChunk) | |||
{ | |||
// First chunk pre-processing | |||
const skipFirstNLines = parseInt(this._config.skipFirstNLines) || 0; | |||
if (this.isFirstChunk && skipFirstNLines > 0) { | |||
const splitChunk = chunk.split('\n'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not hardcode the line break, there is a config setter which defines the valid line breaks and allows the user to change them. Code should work for any of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I changed the code. Unfortunately, made it a bit more complicated because config.newline might be undefined. I used the same approach like here
@pokoli Any update here? |
References #1045