-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A flexible, fast, conduit-based CSV parser library for Haskell. -- -- CSV files are the de-facto standard in many situations involving data -- transfer, particularly when dealing with enterprise application or -- disparate database systems. -- -- While there are a number of CSV libraries in Haskell, at the time of -- this project's start in 2010, there wasn't one that provided all of -- the following: -- -- -- -- This library is an attempt to close these gaps. Please note that this -- library started its life based on the enumerator package and has -- recently been ported to work with conduits instead. In the process, it -- has been greatly simplified thanks to the modular nature of the -- conduits library. -- -- Following the port to conduits, the library has also gained the -- ability to parameterize on the stream type and work both with -- ByteString and Text. -- -- For more documentation and examples, check out the README at: -- -- http://github.com/ozataman/csv-conduit @package csv-conduit @version 0.1 -- | This module exports the underlying Attoparsec row parser. This is -- helpful if you want to do some ad-hoc CSV string parsing. module Data.CSV.Conduit.Parser.Text -- | Try to parse given string as CSV parseCSV :: CSVSettings -> Text -> Either String [Row Text] -- | Try to parse given string as 'Row Text' parseRow :: CSVSettings -> Text -> Either String (Maybe (Row Text)) -- | Parse a CSV row row :: CSVSettings -> Parser (Maybe (Row Text)) -- | Parse CSV csv :: CSVSettings -> Parser [Row Text] -- | This module exports the underlying Attoparsec row parser. This is -- helpful if you want to do some ad-hoc CSV string parsing. module Data.CSV.Conduit.Parser.ByteString -- | Try to parse given string as CSV parseCSV :: CSVSettings -> ByteString -> Either String [Row ByteString] -- | Try to parse given string as 'Row ByteString' parseRow :: CSVSettings -> ByteString -> Either String (Maybe (Row ByteString)) -- | Parse a CSV row row :: CSVSettings -> Parser (Maybe (Row ByteString)) -- | Parse CSV csv :: CSVSettings -> Parser [Row ByteString] module Data.CSV.Conduit -- | Represents types r that can be converted from an underlying -- stream of type s. -- -- Example processing using MapRow Text isntance: -- --
--   test :: IO ()
--   test = runResourceT $ 
--     sourceFile test/BigFile.csv $= 
--     decode utf8 $=
--     intoCSV defCSVSettings $=
--     myMapRowProcessingConduit $=
--     fromCSV defCSVSettings $=
--     encode utf8 $$
--     sinkFile test/BigFileOut.csv
--   
class CSVeable s r rowToStr :: CSVeable s r => CSVSettings -> r -> s intoCSV :: (CSVeable s r, MonadResource m) => CSVSettings -> Conduit s m r fromCSV :: (CSVeable s r, MonadResource m) => CSVSettings -> Conduit r m s -- | Settings for a CSV file. This library is intended to be flexible and -- offer a way to process the majority of text data files out there. data CSVSettings CSVS :: !Char -> !Maybe Char -> !Maybe Char -> !Char -> CSVSettings -- | Separator character to be used in between fields csvSep :: CSVSettings -> !Char -- | Quote character that may sometimes be present around fields. If -- Nothing is given, the library will never expect quotation even -- if it is present. csvQuoteChar :: CSVSettings -> !Maybe Char -- | Quote character that should be used in the output. csvOutputQuoteChar :: CSVSettings -> !Maybe Char -- | Field separator that should be used in the output. csvOutputColSep :: CSVSettings -> !Char -- | Default settings for a CSV file. -- --
--   csvSep = ','
--   csvQuoteChar = Just '"'
--   csvOutputQuoteChar = Just '"'
--   csvOutputColSep = ','
--   
defCSVSettings :: CSVSettings -- | A MapRow is a dictionary based on Map type MapRow a = Map a a -- | A Row is just a list of fields type Row a = [a] -- | Read the entire contents of a CSV file into memory readCSVFile :: (MonadUnsafeIO m, MonadThrow m, MonadBaseControl IO m, MonadIO m, CSVeable ByteString a) => CSVSettings -> FilePath -> m [a] -- | Map over the rows of a CSV file. Don't be scared by the type -- signature, this can just run in IO. mapCSVFile :: (MonadIO m, MonadUnsafeIO m, MonadThrow m, MonadBaseControl IO m, CSVeable ByteString a, CSVeable ByteString b) => CSVSettings -> (a -> b) -> FilePath -> FilePath -> m () instance (CSVeable s (Row s'), Ord s', IsString s) => CSVeable s (MapRow s') instance CSVeable ByteString (Row Text) instance CSVeable Text (Row Text) instance CSVeable ByteString (Row ByteString)