Compare commits
2 Commits
d27eb91952
...
886f991ee3
Author | SHA1 | Date | |
---|---|---|---|
|
886f991ee3 | ||
|
659b817252 |
|
@ -35,15 +35,20 @@ module Data.CSV.Sip (
|
||||||
-- ** Write an entire CSV file
|
-- ** Write an entire CSV file
|
||||||
writeCSV,
|
writeCSV,
|
||||||
writeRawCSV,
|
writeRawCSV,
|
||||||
writeCSVFromStream,
|
|
||||||
writeRawCSVFromStream,
|
|
||||||
-- * Conduits
|
-- * Conduits
|
||||||
-- ** Encoding
|
-- ** Producers
|
||||||
|
readFromCSV,
|
||||||
|
readFromCSVRaw,
|
||||||
encodeCSV,
|
encodeCSV,
|
||||||
encodeRawCSV,
|
encodeRawCSV,
|
||||||
|
-- ** Consumers
|
||||||
|
writeToCSV,
|
||||||
|
writeToCSVRaw,
|
||||||
|
-- ** Transformers
|
||||||
|
-- *** Encoding
|
||||||
encodeRows,
|
encodeRows,
|
||||||
encodeRawRows,
|
encodeRawRows,
|
||||||
-- ** Decoding
|
-- *** Decoding
|
||||||
labelFields,
|
labelFields,
|
||||||
decodeRows,
|
decodeRows,
|
||||||
decodeRawRows,
|
decodeRawRows,
|
||||||
|
@ -127,27 +132,21 @@ writeRawCSV
|
||||||
-> m ()
|
-> m ()
|
||||||
writeRawCSV file csv = runConduit $ encodeRawCSV csv .| sinkFile file
|
writeRawCSV file csv = runConduit $ encodeRawCSV csv .| sinkFile file
|
||||||
|
|
||||||
-- | Write a CSV file from a stream of Text-based rows
|
-- | reads a stream of Text-based rows from a CSV file
|
||||||
writeCSVFromStream
|
readFromCSV
|
||||||
:: MonadResource m
|
:: MonadResource m
|
||||||
=> FilePath
|
=> FilePath
|
||||||
-- ^ the path to the file to write to
|
-- ^ the path to the CSV file to read from
|
||||||
-> ConduitT () [T.Text] m ()
|
-> ConduitT i [T.Text] m ()
|
||||||
-- ^ the source conduit
|
readFromCSV file = sourceFile file .| decodeRows
|
||||||
-> m ()
|
|
||||||
writeCSVFromStream file src = runConduit $
|
|
||||||
src .| encodeRows .| sinkFile file
|
|
||||||
|
|
||||||
-- | Write a CSV file from a stream of ByteString-based rows
|
-- | reads a stream of ByteString-based rows from a CSV file
|
||||||
writeRawCSVFromStream
|
readFromCSVRaw
|
||||||
:: MonadResource m
|
:: MonadResource m
|
||||||
=> FilePath
|
=> FilePath
|
||||||
-- ^ the path to the file to write to
|
-- ^ the path to the CSV file to read from
|
||||||
-> ConduitT () [BS.ByteString] m ()
|
-> ConduitT i [BS.ByteString] m ()
|
||||||
-- ^ the source conduit
|
readFromCSVRaw file = sourceFile file .| decodeRawRows
|
||||||
-> m ()
|
|
||||||
writeRawCSVFromStream file src = runConduit $
|
|
||||||
src .| encodeRawRows .| sinkFile file
|
|
||||||
|
|
||||||
-- | encode an entire CSV file
|
-- | encode an entire CSV file
|
||||||
encodeCSV
|
encodeCSV
|
||||||
|
@ -165,6 +164,22 @@ encodeRawCSV
|
||||||
-> ConduitT () BS.ByteString m ()
|
-> ConduitT () BS.ByteString m ()
|
||||||
encodeRawCSV csv = sourceList csv .| encodeRawRows
|
encodeRawCSV csv = sourceList csv .| encodeRawRows
|
||||||
|
|
||||||
|
-- | Writes a stream of Text-based rows to a CSV file
|
||||||
|
writeToCSV
|
||||||
|
:: MonadResource m
|
||||||
|
=> FilePath
|
||||||
|
-- ^ the path to the CSV file to write to
|
||||||
|
-> ConduitT [T.Text] o m ()
|
||||||
|
writeToCSV file = encodeRows .| sinkFile file
|
||||||
|
|
||||||
|
-- | Writes a stream of ByteString-based rows to a CSV file
|
||||||
|
writeToCSVRaw
|
||||||
|
:: MonadResource m
|
||||||
|
=> FilePath
|
||||||
|
-- ^ the path to the CSV file to write to
|
||||||
|
-> ConduitT [BS.ByteString] o m ()
|
||||||
|
writeToCSVRaw file = encodeRawRows .| sinkFile file
|
||||||
|
|
||||||
-- | encode a CSV stream row by row, each element in the list read
|
-- | encode a CSV stream row by row, each element in the list read
|
||||||
-- represents a field, with the entire list representing a row
|
-- represents a field, with the entire list representing a row
|
||||||
encodeRows :: Monad m => ConduitT [T.Text] BS.ByteString m ()
|
encodeRows :: Monad m => ConduitT [T.Text] BS.ByteString m ()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user