| Copyright | (C) Jonathan Lamothe |
|---|---|
| License | GPL-3.0-or-later |
| Maintainer | jonathan@jlamothe.net |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.CSV.Sip
Description
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Synopsis
- slurpCSV :: MonadResource m => FilePath -> m [[Text]]
- slurpRawCSV :: MonadResource m => FilePath -> m [[ByteString]]
- slurpLabelledCSV :: MonadResource m => FilePath -> m [Map Text Text]
- slurpRawLabelledCSV :: MonadResource m => FilePath -> m [Map ByteString ByteString]
- writeCSV :: MonadResource m => FilePath -> [[Text]] -> m ()
- writeRawCSV :: MonadResource m => FilePath -> [[ByteString]] -> m ()
- readFromCSV :: MonadResource m => FilePath -> ConduitT i [Text] m ()
- readFromCSVRaw :: MonadResource m => FilePath -> ConduitT i [ByteString] m ()
- encodeCSV :: Monad m => [[Text]] -> ConduitT () ByteString m ()
- encodeRawCSV :: Monad m => [[ByteString]] -> ConduitT () ByteString m ()
- writeToCSV :: MonadResource m => FilePath -> ConduitT [Text] o m ()
- writeToCSVRaw :: MonadResource m => FilePath -> ConduitT [ByteString] o m ()
- encodeRows :: Monad m => ConduitT [Text] ByteString m ()
- encodeRawRows :: Monad m => ConduitT [ByteString] ByteString m ()
- labelFields :: (Monad m, Ord a) => ConduitT [a] (Map a a) m ()
- decodeRows :: Monad m => ConduitT ByteString [Text] m ()
- decodeRawRows :: Monad m => ConduitT ByteString [ByteString] m ()
- decodeUTF8 :: ByteString -> Maybe Text
- toBytes :: Monad m => ConduitT ByteString Word8 m ()
Working with Files
Read an entire CSV file
Arguments
| :: MonadResource m | |
| => FilePath | the path to the file to read |
| -> m [[Text]] |
read an entire CSV file
Arguments
| :: MonadResource m | |
| => FilePath | the path to the file to read |
| -> m [[ByteString]] |
read an entire CSV file in raw mode
Arguments
| :: MonadResource m | |
| => FilePath | the path to the file to read |
| -> m [Map Text Text] |
read an entire CSV file with a header
Arguments
| :: MonadResource m | |
| => FilePath | the path to the file to read |
| -> m [Map ByteString ByteString] |
read an entire CSV file with a header
Write an entire CSV file
Arguments
| :: MonadResource m | |
| => FilePath | the path to the file to write to |
| -> [[Text]] | the fields/rows being written |
| -> m () |
write a CSV file from Text-based rows
Arguments
| :: MonadResource m | |
| => FilePath | the path to the file to write to |
| -> [[ByteString]] | the fields/rows being written |
| -> m () |
write a CSV file from raw ByteString-based rows
Conduits
Producers
Arguments
| :: MonadResource m | |
| => FilePath | the path to the CSV file to read from |
| -> ConduitT i [Text] m () |
reads a stream of Text-based rows from a CSV file
Arguments
| :: MonadResource m | |
| => FilePath | the path to the CSV file to read from |
| -> ConduitT i [ByteString] m () |
reads a stream of ByteString-based rows from a CSV file
Arguments
| :: Monad m | |
| => [[Text]] | the data being encoded, organized into rows and fields |
| -> ConduitT () ByteString m () |
encode an entire CSV file
Arguments
| :: Monad m | |
| => [[ByteString]] | the data being encoded, organized into rows and fields |
| -> ConduitT () ByteString m () |
encode an entire CSV file
Consumers
Arguments
| :: MonadResource m | |
| => FilePath | the path to the CSV file to write to |
| -> ConduitT [Text] o m () |
Writes a stream of Text-based rows to a CSV file
Arguments
| :: MonadResource m | |
| => FilePath | the path to the CSV file to write to |
| -> ConduitT [ByteString] o m () |
Writes a stream of ByteString-based rows to a CSV file
Transformers
Encoding
encodeRows :: Monad m => ConduitT [Text] ByteString m () Source #
encode a CSV stream row by row, each element in the list read represents a field, with the entire list representing a row
encodeRawRows :: Monad m => ConduitT [ByteString] ByteString m () Source #
encode raw CSV stream row by row, each element in the list read represents a field, with the entire list representing a row
Decoding
labelFields :: (Monad m, Ord a) => ConduitT [a] (Map a a) m () Source #
read a CSV stream, using the first row as a header containing field labels
decodeRows :: Monad m => ConduitT ByteString [Text] m () Source #
decode the rows from a stream of ByteStrings
decodeRawRows :: Monad m => ConduitT ByteString [ByteString] m () Source #
decode the rows returning raw ByteStrings instead of text
decodeUTF8 :: ByteString -> Maybe Text Source #
decode a raw ByteString into Text (if possible)