Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Empty lines not skipped #122

Closed
tulika-agr opened this issue Jan 9, 2017 · 5 comments
Closed

Empty lines not skipped #122

tulika-agr opened this issue Jan 9, 2017 · 5 comments

Comments

@tulika-agr
Copy link

var csv = require("csv")
var report = "Date,Value\n" +
"2016/02/11,5341022\n" +
"2016/02/12,4771\n" +
"2016/02/12,5341022\n\n\n";
var csvOpts = {columns: true, skip_empty_lines: true, trim: true, auto_parse: true};
csv.parse(report, csvOpts, function(err, data) {
console.log(data);
});
The above code prints 4 objects instead of 3. The last one has a single field "Date"
0: Object {Date: "2016/02/11", …}
1: Object {Date: "2016/02/12", …}
2: Object {Date: "2016/02/12", …}
3: Object {Date: ""…}

@JacobLynch
Copy link

I just noticed this same issue in our setup and came here to note it, thanks. Although in our case it doesn't look like we have any empty lines at the end, it just simply passes an empty object for the last row parsed (after the last valid row).

@wdavidw
Copy link
Member

wdavidw commented Jan 9, 2017

seems related to one of the latest commit, will look soon

@JacobLynch
Copy link

Yes, I reverted to 1.1.0, and it's back to normal.

@wdavidw
Copy link
Member

wdavidw commented Jan 9, 2017

shall be fixed now with 1.1.9

@tulika-agr
Copy link
Author

Thanks, fixed now.

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

No branches or pull requests

3 participants