deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

csv/parse-stream: syntax error handling

Open mfulton26 opened this issue 11 months ago • 0 comments

Is your feature request related to a problem? Please describe.

I want to watch a CSV file and recompute some statistics each time it changes. Sometimes the last record is incomplete:

Error: Syntax error on line 156: The record has 2 fields, but the header has 4 fields

Describe the solution you'd like

A way to handle syntax errors and continue parsing the stream rather than throwing and halting stream parsing.

e.g. onSyntaxError() option to the CsvParseStream constructor. The function can return a completed record or return something like undefined to skip the record.

Describe alternatives you've considered

Building my own stream transforming to detect an incomplete last line and not pipe it through to the CsvParseStream instance.

mfulton26 avatar Jan 17 '25 15:01 mfulton26