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}]

#parseRaw Source

parseRaw :: Pipe (Maybe Buffer) (Maybe (Array String)) Aff Unit

Transforms buffer chunks of a CSV file to parsed arrays of CSV values.

#stringifyRaw Source

stringifyRaw :: Array String -> Pipe (Maybe (Array String)) (Maybe String) Aff Unit

Transforms CSV rows into stringified CSV records using the given ordered array of column names.

#stringify Source

stringify :: forall r rl. WriteCSVRecord r rl => RowToList r rl => Keys rl => Pipe (Maybe (Record r)) (Maybe String) Aff Unit

Transforms purescript records into stringified CSV records.

Columns are inferred from the record's keys, ordered alphabetically.