0

I am using papa parse to read a csv file hosted remotely. The issue is that header row is not in the first line of the file, instead, the file begins with a few empty lines, then we have the header row, and then all data. I am struggling to get papa parse to ignore the empty lines at the beginning of the file. Is there something that I'm missing? I'd like to avoid loading whole the whole file (need only first few rows from over 6000 rows).

    filename = "myName.csv"

Papa.parse('data/gen/csv/'.concat(filename), {
    download: true,
    delimiter: ",",
    newline: "↵",
    header: true,
    dynamicTyping: true,
    skipEmptyLines: true,
    preview: 30,
    step: function(row) {
        console.log("Row:", row.data);
    },
    complete: function() {
        console.log("All done!");
    }
});
LucasSeveryn
  • 5,984
  • 8
  • 38
  • 65
  • Is that actually the newline character? – ragerory Jun 03 '15 at 18:18
  • you're talking about that arrow? In that case, it appears like this in chrome's inspector, if I dont specify this it'll be a single row – LucasSeveryn Jun 03 '15 at 18:26
  • Yeah, I was asking because I was wondering if this was coming in as a single row with that line delimiter. I would think it would be `\n` or `\r\n`... Might want to test that just in case, couldn't hurt. – ragerory Jun 03 '15 at 18:29

1 Answers1

0

My guess is that the blank lines in your CSV are not actual line breaks.

If you try pasting your CSV into the Papa Parse demo, http://papaparse.com/demo, click parse and then view the results in the browser console, it will display how many rows are counted which includes the blank lines. If your blank lines aren't being counted, then I think you can safely assume the blank lines are not being rendered as \r or \n.

Another way is, if you have Microsoft Word you can paste the text into a blank doc and click the option to view line breaks. All blank lines should display the line break symbol.

If you can confirm they are not true line breaks, then if possible, go to the source of the CSV's and see how the files are being generated.

ajbazz
  • 11
  • 2