PapaParse
PapaParse copied to clipboard
Complete callback does not fire when Step and Preview used together
So, I don't think this actually a bug, just potentially confusing, although I was ultimately able to make sense out of it:
If you pass both preview
and step
options and your data source has more than preview
rows, then the complete
callback never fires. Although, it just so happens that if your data source has the same number of rows as preview
, then the complete
callback fires even if you have also defined a step
callback. I haven't tested if complete
also fires in these circumstances if the data source as fewer than preview
rows, but you get the picture.
Again, not exactly a bug, but I wanted to drop a note here.
it also doesn't fire when chunk is used and file size is less than chunk size. (meaning chunk is only called once for file)
Can confirm that complete
does fire when the amount of lines is less than the preview
specified, but not when the amount of lines is longer than preview
Again, not exactly a bug
Would definitely consider this a bug.
It's not a bug, because the intention was that complete
only fires when the full input has been read, which preview
prevents from happening if the input is longer. However, the docs aren't clear because they say "when parsing is complete" -- we should either clarify the docs or change the behavior to call complete
when the preview (if any) is also done parsing.
This also happens when using in Node with the Papa.NODE_STREAM_INPUT to parse a stream with the preview configuration option. Spent a few hours trying to figure out what I did wrong before I realized that the Papa.parse stream never fires the end event if the preview rows are all received before the source stream is completely processed.
If avoiding changes to the current behavior is important it may work to either add a new event (maybe finish or done or something like that) to indicate that Papa.parse is doing no further parsing, or perhaps to fire an end event when the underlying stream that is being piped to Papa.parse fires its own end event.
Any update on this? This I agree is an important feature - having a callback even if preview is true. The last post I thought would be a great compromise to all of the solutions mentioned here.
Any update on this?
I'd be interested in a clean solution for this one.