adaltas / node-csv

Full featured CSV parser with simple api and tested against large datasets.
https://csv.js.org
MIT License
4.05k stars 267 forks source link

Parse CSV from ReadableStream in the browser #353

Closed chucklay closed 2 years ago

chucklay commented 2 years ago

Summary

Unsure if this is possible or not, Either way, the documentation should be more clear as to if this is or is not possible. Regardless, I would like to be able to parse a CSV contained in a ReadableStream (as returned by the browser implementation of fetch). Currently, attempting to use PipeThrough to send a ReadableStream through a parser fails due to the parser's readable property being Boolean instead of a ReadableStream

Motivation

Currently, I'm trying to parse a CSV returned by a fetch. As the CSVs returned here can be significantly large, the line-by-line parsing in the pipe recipe would be extremely useful and would be very useful in avoiding blowing up memory. However, I don't see a way to use ReadableStream.PipeThrough here. This may be a gap in my own knowledge, but the documentation on using this parser in the browser after being run through webpack is fairly sparse. Reading data from a stream seems like a fairly common use case, so this would be nice to support.

wdavidw commented 2 years ago

Please provide a sample.

chucklay commented 2 years ago

Disregard, my issues wound up being caused webpack > 5 not polyfilling dependencies of the node standard library that I had configured it to polyfill. Sorry about the extra issue!