csv-sip-0.1.0: extracts data from a CSV file
Copyright(C) Jonathan Lamothe
LicenseGPL-3.0-or-later
Maintainerjonathan@jlamothe.net
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

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

Working with Files

Read an entire CSV file

slurpCSV Source #

Arguments

:: MonadResource m 
=> FilePath

the path to the file to read

-> m [[Text]] 

read an entire CSV file

slurpRawCSV Source #

Arguments

:: MonadResource m 
=> FilePath

the path to the file to read

-> m [[ByteString]] 

read an entire CSV file in raw mode

slurpLabelledCSV Source #

Arguments

:: MonadResource m 
=> FilePath

the path to the file to read

-> m [Map Text Text] 

read an entire CSV file with a header

slurpRawLabelledCSV Source #

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

writeCSV Source #

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

writeRawCSV Source #

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

readFromCSV Source #

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

readFromCSVRaw Source #

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

encodeCSV Source #

Arguments

:: Monad m 
=> [[Text]]

the data being encoded, organized into rows and fields

-> ConduitT () ByteString m () 

encode an entire CSV file

encodeRawCSV Source #

Arguments

:: Monad m 
=> [[ByteString]]

the data being encoded, organized into rows and fields

-> ConduitT () ByteString m () 

encode an entire CSV file

Consumers

writeToCSV Source #

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

writeToCSVRaw Source #

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)

toBytes :: Monad m => ConduitT ByteString Word8 m () Source #

convert a stream to ByteStrings to a string of bytes