-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A flexible, fast, enumerator-based CSV parser library for Haskell. -- -- For more information and examples, check out the README at: -- http://github.com/ozataman/csv-enumerator. The API is fairly -- well documented and I would encourage you to keep your haddocks handy. @package csv-enumerator @version 0.8 module Data.CSV.Enumerator type Row = [Field] type Field = ByteString type MapRow = Map ByteString ByteString class CSVeable r rowToStr :: CSVeable r => CSVSettings -> r -> ByteString fileHeaders :: CSVeable r => [r] -> Maybe Row iterCSV :: CSVeable r => CSVSettings -> CSVAction r a -> a -> Iteratee ByteString IO a fileSink :: CSVeable r => CSVSettings -> FilePath -> (Maybe Handle, Int) -> ParsedRow r -> Iteratee ByteString IO (Maybe Handle, Int) foldCSVFile :: CSVeable r => FilePath -> CSVSettings -> CSVAction r a -> a -> IO (Either SomeException a) mapCSVFile :: CSVeable r => FilePath -> CSVSettings -> (r -> [r]) -> FilePath -> IO (Either SomeException Int) mapCSVFiles :: CSVeable r => [FilePath] -> CSVSettings -> (r -> [r]) -> FilePath -> IO (Either SomeException Int) -- | A datatype that incorporates the signaling of parsing status to the -- user-developed iteratee. -- -- We need this because some iteratees do interleaved IO (such as -- outputting to a file via a handle inside the accumulator) and some -- final actions may need to be taken upon encountering EOF (such as -- closing the interleaved handle). -- -- Use this datatype when developing iteratees for use with fold* family -- of functions (Row enumarators). data CSVeable r => ParsedRow r ParsedRow :: (Maybe r) -> ParsedRow r EOF :: ParsedRow r -- | 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 readCSVFile :: CSVeable r => CSVSettings -> FilePath -> IO (Either SomeException [r]) writeCSVFile :: CSVeable r => CSVSettings -> FilePath -> [r] -> IO Int appendCSVFile :: CSVeable r => CSVSettings -> FilePath -> [r] -> IO Int -- | An iteratee that processes each row of a CSV file and updates the -- accumulator. -- -- You would implement one of these to use with the foldCSVFile -- function. type CSVAction r a = a -> ParsedRow r -> Iteratee ByteString IO a -- | Convenience converter for fold step functions that are pure. -- -- Use this if you don't want to deal with Iteratees when writing your -- fold functions. funToIter :: CSVeable r => (a -> ParsedRow r -> a) -> CSVAction r a -- | Convenience converter for fold step functions that live in the IO -- monad. -- -- Use this if you don't want to deal with Iteratees when writing your -- fold functions. funToIterIO :: CSVeable r => (a -> ParsedRow r -> IO a) -> CSVAction r a -- | Just collect all rows into an array. This will cancel out the -- incremental nature of this library. collectRows :: CSVeable r => CSVAction r [r] outputRowIter :: CSVeable r => CSVSettings -> Handle -> r -> Iteratee ByteString IO () outputRowsIter :: CSVeable r => CSVSettings -> Handle -> [r] -> Iteratee ByteString IO () -- | Output given row into given handle outputRow :: CSVeable r => CSVSettings -> Handle -> r -> IO () outputRows :: CSVeable r => CSVSettings -> Handle -> [r] -> IO () writeHeaders :: CSVeable r => CSVSettings -> Handle -> [r] -> IO () instance CSVeable MapRow instance CSVeable Row