mholt/PapaParse

meta.cursor value is incorrect if you use parser.pause() and parser.resume()

Open

#321 geöffnet am 7. Juli 2016

Auf GitHub ansehen
 (10 Kommentare) (4 Reaktionen) (0 zugewiesene Personen)JavaScript (1.157 Forks)batch import
help wanted

Repository-Metriken

Stars
 (11.877 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

I'm trying to make use of meta.cursor to display a progress bar. The following example works fine:

Papa.parse(file, {
    step: function(results, parser){
         // This gives expected result for cursor
         console.info(result.meta.cursor);
     }
}

Unfortunately, if I make use of parser.pause() and parser.resume() the value for meta.cursor is incorrect. Instead of getting an incrementing value I end up getting a seemingly random number that stays fairly constant and does not add up to the total file size if I sum it up.

Papa.parse(file, {
     step: function(results, parser){
             // This does not give the correct value for cursor
             console.info(result.meta.cursor);
             parser.pause();
             parser.resume();
      }
}

I need to pause the stream because I send the data in chunks to the server for processing and wait for the server to finish before sending the next chunk of data.

Thank you!

Contributor Guide