Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ozataman committed Apr 29, 2011
1 parent fbf11ce commit 8ca03c9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
29 changes: 24 additions & 5 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,31 @@ 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:
project's start in 2010, there wasn't one that provided all of the following:

* Full flexibility in quote characters, separators, input/output
* Constant space operation
* Robust parsing and error resiliency
* Fast operation
* Convenient interface that supports a variety of use cases

This library is an attempt to close this gap.


## This package

csv-iteratee is an enumerator-based CSV parsing library that is easy to use, flexible and fast.
csv-iteratee is an enumerator-based CSV parsing library that is easy to use,
flexible and fast. Furthermore, it provides ways to use constant-space during
operation, which is absolutely critical in many real world use cases.


### Introduction

* ByteStrings are used for everything
* There are 2 basic row types and they implement *exactly* the same operations,
so you can chose the right one for the job at hand:
- type MapRow :: Map ByteString ByteString
- type Row :: [ByteString]
- type MapRow = Map ByteString ByteString
- type Row = [ByteString]
* Folding over a CSV file can be thought of as the most basic operation.
* Higher level convenience functions are provided to "map" over CSV files,
modifying and transforming them along the way.
Expand All @@ -53,11 +57,13 @@ regressions or optimization opportunities.

{-# LANGUAGE OverloadedStrings #-}

import Data.CSV.Iteratee
import Data.Char (isSpace)
import qualified Data.Map as M
import Data.Map ((!))

-- Naive whitespace stripper
strip = reverse . B.dropWhile isChar . reverse . B.dropWhile isChar
strip = reverse . B.dropWhile isSpace . reverse . B.dropWhile isSpace

-- A function that takes a row and "emits" zero or more rows as output.
processRow :: MapRow -> [MapRow]
Expand All @@ -71,3 +77,16 @@ and we are done.

Further examples to be provided at a later time.



### TODO - Next Steps

* Some operations can be further broken down to their atoms, increasing the
flexibility of the library.
* The CSVeable typeclass can be refactored to have a more minimal definition.
* Operating on Text in addition to ByteString would be phenomenal.
* A test-suite needs to be added.


Any and all kinds of help is much appreciated!

9 changes: 8 additions & 1 deletion csv-iteratee.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: csv-iteratee
Version: 0.8
Synopsis: An enumerator-based, flexible, fast, constant-memory CSV parser library for Haskell.
Synopsis: An enumerator-based, flexible, fast, constant-memory CSV parser library for Haskell.
Homepage: http://github.com/ozataman/csv-iteratee
License: BSD3
License-file: LICENSE
Expand All @@ -9,6 +9,13 @@ Maintainer: ozataman@gmail.com
Category: Data
Build-type: Simple
Cabal-version: >=1.2
Description:
For more information and examples, check out the README at:
<http://github.com/ozataman/csv-iteratee>.

The API is fairly well documented and I would encourage you to keep your
haddocks handy.


extra-source-files:
Examples/*.hs
Expand Down

0 comments on commit 8ca03c9

Please sign in to comment.