PapaParse icon indicating copy to clipboard operation
PapaParse copied to clipboard

preview + step never completes

Open designfrontier opened this issue 6 years ago • 3 comments

The discussion (in #352) and the docs indicate that the meta.truncated value should become true when the last row to preview is parsed. But it doesn't it remains false and complete is never called. This means short of keeping your own counter there is no way to know that preview has completed.

To repro:

  • Go to the demo.
  • Select local file.
  • check Stream option.
  • Set preview to any positive non-zero value
  • Click parse
  • Nothing ever shows up in the console

designfrontier avatar Jan 21 '19 22:01 designfrontier

I am having the same issue. I think that the current behavior where complete() is not called if preview is specified is not very intuitive.

At a minimum, there should be some way to detect that parsing is "done", maybe fire some other new event to indicate that truncated parsing is done, or at least ensure meta.truncated=true so that as an implementer we don't have to manually keep track of the rows processed to know when preview is finished.

Here is my configuration:

parse(fs.createReadStream(filename, 'utf-8'), {
  preview: 1,
  header: true,
  skipEmptyLines: true,
  step: row => {
    this.log.debug('CSV parsed row');
    // row.meta.truncate is always false
  },
  error: error => {
    this.log.debug('Errors parsing file', error);
  },
  complete: () => {
    // never called
});

paustint avatar Feb 02 '19 13:02 paustint

Still facing the same issue

chavda-bhavik avatar Sep 13 '23 13:09 chavda-bhavik

still facing this issue. can a previewComplete callback be added?

hasti123 avatar Jan 05 '24 05:01 hasti123