Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is PapaParse adding an empty string to the end of its data array?

Tags:

papaparse

Papa Parse seems wise, but I think he might be giving me null. I'm just:

 Papa.parse(countries);

Where countries is a string containing the XMLHttpRequest of the countries csv file from a timezone database here: https://timezonedb.com/download

But Papa Parse seems to have added an empty array to the end of it's data array. So when I'm searching and sorting through the array, that one empty guy at the end is giving me troubles. I can write around it but it's not ideal, and I thought Papa Parse was supposed to make those kind of csv parsing problems go away. Am I Parsing wrong?

Here is the end of the PapaParsed Array in console: Papa why?

like image 766
kidconcept Avatar asked Jan 30 '17 19:01

kidconcept


2 Answers

You need to use skipEmptyLines: true in parse config. For example:

Papa.parse(this.csvData, {skipEmptyLines: true,})
like image 157
Alex Fomushkin Avatar answered Sep 21 '22 17:09

Alex Fomushkin


it was adding empty line to my iteration as well. i decided to skip it by doing loop:

for(let i=0;i<data.length -1;i++){
like image 36
Marcin Buglewicz Avatar answered Sep 20 '22 17:09

Marcin Buglewicz