Streaming csv parser using cassava and pipes
Haskell Shell Makefile
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src/Pipes
test
travis
.gitignore
.travis.yml
LICENSE
Makefile
Readme.md
Setup.hs
pipes-csv.cabal

Readme.md

pipes-csv

Constant-space streaming csv parsing with cassava and pipes

build status

Installation

Install with cabal

$ cabal install pipes-csv

Example

{-# LANGUAGE OverloadedStrings #-}

import Pipes.Csv (decode, decodeByName)
import Pipes.ByteString (stdin, ByteString)
import Data.Csv ((.:), FromNamedRecord(..), Record)
import Pipes
import Control.Applicative

data Person = Person String Int
            deriving (Show)

instance FromNamedRecord Person where
  parseNamedRecord p =
    Person <$> p .: "name"
           <*> p .: "age"

persons :: Monad m
        => Producer ByteString m ()
        -> Producer (Either String Person) m ()
persons = decodeByName

main = runEffect $ for (persons stdin) (lift . print)

License

MIT