Search code examples
papaparse

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


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?


Solution

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

    Papa.parse(this.csvData, {skipEmptyLines: true,})