cassava-0.2.0.0: A CSV parsing and encoding library

Safe HaskellNone

Data.Csv.Streaming

Description

This module allows for streaming decoding of CSV data. This is useful if you need to parse large amounts of input in constant space. The API also allows you to ignore type conversion errors on a per-record basis.

Synopsis

Documentation

data Records a Source

A stream of parsed records. If type conversion failed for the record, the error is returned as Left errMsg.

Constructors

Cons (Either String a) (Records a)

A record or an error message, followed by more records.

Nil (Maybe String) ByteString

End of stream, potentially due to a parse error. If a parse error occured, the first field contains the error message. The second field contains any unconsumed input.

decodeSource

Arguments

:: FromRecord a 
=> Bool

Data contains header that should be skipped

-> ByteString

CSV data

-> Records a 

Efficiently deserialize CSV records in a streaming fashion. Equivalent to decodeWith defaultDecodeOptions.

decodeWithSource

Arguments

:: FromRecord a 
=> DecodeOptions

Decoding options

-> Bool

Data contains header that should be skipped

-> ByteString

CSV data

-> Records a 

Like decode, but lets you customize how the CSV data is parsed.

decodeByNameSource

Arguments

:: FromNamedRecord a 
=> ByteString

CSV data

-> Either String (Header, Records a) 

Efficiently deserialize CSV in a streaming fashion. The data is assumed to be preceeded by a header. Returns Left errMsg if parsing the header fails. Equivalent to decodeByNameWith defaultDecodeOptions.

decodeByNameWithSource

Arguments

:: FromNamedRecord a 
=> DecodeOptions

Decoding options

-> ByteString

CSV data

-> Either String (Header, Records a) 

Like decodeByName, but lets you customize how the CSV data is parsed.