Module
Pipes.CSV
- Package
- purescript-csv-stream
- Repository
- cakekindel/purescript-csv-stream
#parse Source
parse :: forall @r rl. RowToList r rl => ReadCSVRecord r rl => Pipe (Maybe Buffer) (Maybe (Record r)) Aff Unit
Transforms buffer chunks of a CSV file to parsed
records of r
.
-- == my-data.csv.gz ==
-- id,foo,is_deleted
-- 1,hi,f
-- 2,bye,t
rows
:: Array {id :: Int, foo :: String, is_deleted :: Boolean}
<- map Array.fromFoldable
$ Pipes.toListM
$ Pipes.Node.Stream.unEOS
$ Pipes.Node.FS.read "my-data.csv.gz"
>-> Pipes.Node.Zlib.gunzip
>-> Pipes.CSV.parse
rows `shouldEqual` [{id: 1, foo: "hi", is_deleted: false}, {id: 2, foo: "bye", is_deleted: true}]