Closed nerdstep closed 1 year ago
that said, maybe what I'm really asking for is the ability to parse a file stream... but perhaps that is outside of the scope for what you intend this project to do?
@nerdstep Streaming is an amazing missing feature for sure, but I am not sure how to do it for both node and browser. This is an interesting implementation of how to split CSV files. I think I would do something similar here. https://github.com/alex-murashkin/csv-split-stream#readme
Maybe to resolve this issue we should consider adding a new method to check if row is valid against schema. What do you think, is it sufficient for you @nerdstep
@bartoszgolebiowski -- I think streaming can be achieved in both node and browser, since the browser also supports a Streams API. The Papa Parse library does this too.
That said, if you wanted to keep this library small and avoid those implementation details, then a row validation method would make sense.
https://github.com/bartoszgolebiowski/zod-csv/pull/2
This is a draft, I am open to naming, typing, and other suggestions!
I introduced a new method: https://github.com/bartoszgolebiowski/zod-csv/blob/main/src/csv.ts#L173 Here is some basic usage: https://github.com/bartoszgolebiowski/zod-csv/blob/main/src/csv.test.ts#L390
nice work and thanks for the quick turnaround!
@bartoszgolebiowski would it be possible to support an option to skip reading the header?
my current use-case is reading a file stream line by line and wanting to parse each line individually.