implemented file producers/consumers
- readFromCSV - readFromCSVRaw - writeToCSV - writeToCSVRaw
This commit is contained in:
parent
659b817252
commit
886f991ee3
@ -36,12 +36,19 @@ module Data.CSV.Sip (
|
|||||||
writeCSV,
|
writeCSV,
|
||||||
writeRawCSV,
|
writeRawCSV,
|
||||||
-- * 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,
|
||||||
@ -125,6 +132,22 @@ writeRawCSV
|
|||||||
-> m ()
|
-> m ()
|
||||||
writeRawCSV file csv = runConduit $ encodeRawCSV csv .| sinkFile file
|
writeRawCSV file csv = runConduit $ encodeRawCSV csv .| sinkFile file
|
||||||
|
|
||||||
|
-- | reads a stream of Text-based rows from a CSV file
|
||||||
|
readFromCSV
|
||||||
|
:: MonadResource m
|
||||||
|
=> FilePath
|
||||||
|
-- ^ the path to the CSV file to read from
|
||||||
|
-> ConduitT i [T.Text] m ()
|
||||||
|
readFromCSV file = sourceFile file .| decodeRows
|
||||||
|
|
||||||
|
-- | reads a stream of ByteString-based rows from a CSV file
|
||||||
|
readFromCSVRaw
|
||||||
|
:: MonadResource m
|
||||||
|
=> FilePath
|
||||||
|
-- ^ the path to the CSV file to read from
|
||||||
|
-> ConduitT i [BS.ByteString] m ()
|
||||||
|
readFromCSVRaw file = sourceFile file .| decodeRawRows
|
||||||
|
|
||||||
-- | encode an entire CSV file
|
-- | encode an entire CSV file
|
||||||
encodeCSV
|
encodeCSV
|
||||||
:: Monad m
|
:: Monad m
|
||||||
@ -141,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…
x
Reference in New Issue
Block a user