All Projects → haskell-hvr → Cassava

haskell-hvr / Cassava

Licence: other
A CSV parsing and encoding library optimized for ease of use and high performance

Programming Languages

haskell
3896 projects

Projects that are alternatives of or similar to Cassava

Jsoncons
A C++, header-only library for constructing JSON and JSON-like data formats, with JSON Pointer, JSON Patch, JSON Schema, JSONPath, JMESPath, CSV, MessagePack, CBOR, BSON, UBJSON
Stars: ✭ 400 (+107.25%)
Mutual labels:  csv-parser
Csv File Validator
🔧🔦 Validation of CSV file against user defined schema (returns back object with data and invalid messages)
Stars: ✭ 60 (-68.91%)
Mutual labels:  csv-parser
React Papaparse
react-papaparse is the fastest in-browser CSV (or delimited text) parser for React. It is full of useful features such as CSVReader, CSVDownloader, readString, jsonToCSV, readRemoteFile, ... etc.
Stars: ✭ 116 (-39.9%)
Mutual labels:  csv-parser
Csvutil
csvutil provides fast and idiomatic mapping between CSV and Go (golang) values.
Stars: ✭ 501 (+159.59%)
Mutual labels:  csv-parser
Faster Than Csv
Faster CSV on Python 3
Stars: ✭ 52 (-73.06%)
Mutual labels:  csv-parser
Ngx Papaparse
Papa Parse wrapper for Angular
Stars: ✭ 83 (-56.99%)
Mutual labels:  csv-parser
Awesomecsv
🕶️A curated list of awesome tools for dealing with CSV.
Stars: ✭ 305 (+58.03%)
Mutual labels:  csv-parser
React Csv Reader
React component that handles csv file input and its parsing
Stars: ✭ 138 (-28.5%)
Mutual labels:  csv-parser
Csv
Fast C# CSV parser
Stars: ✭ 53 (-72.54%)
Mutual labels:  csv-parser
Papaparse
Fast and powerful CSV (delimited text) parser that gracefully handles large files and malformed input
Stars: ✭ 10,206 (+5188.08%)
Mutual labels:  csv-parser
Filehelpers
The FileHelpers are a free and easy to use .NET library to read/write data from fixed length or delimited records in files, strings or streams
Stars: ✭ 917 (+375.13%)
Mutual labels:  csv-parser
Fast Csv
CSV parser and formatter for node
Stars: ✭ 1,054 (+446.11%)
Mutual labels:  csv-parser
Csv Parser
Fast, header-only, extensively tested, C++11 CSV parser
Stars: ✭ 90 (-53.37%)
Mutual labels:  csv-parser
Vroom
Fast reading of delimited files
Stars: ✭ 462 (+139.38%)
Mutual labels:  csv-parser
Etl.net
Mass processing data with a complete ETL for .net developers
Stars: ✭ 129 (-33.16%)
Mutual labels:  csv-parser
Csv Parser
A modern C++ library for reading, writing, and analyzing CSV (and similar) files.
Stars: ✭ 359 (+86.01%)
Mutual labels:  csv-parser
Csvparser
A swift package for read and write CSV file
Stars: ✭ 73 (-62.18%)
Mutual labels:  csv-parser
Csv2
Fast CSV parser and writer for Modern C++
Stars: ✭ 164 (-15.03%)
Mutual labels:  csv-parser
Dataclass Csv
Map CSV to Data Classes
Stars: ✭ 133 (-31.09%)
Mutual labels:  csv-parser
Csv Stream
📃 Streaming CSV Parser for Node. Small and made entirely out of streams.
Stars: ✭ 98 (-49.22%)
Mutual labels:  csv-parser

cassava: A CSV parsing and encoding library Hackage Build Status

Please refer to the package description for an overview of cassava.

Usage example

Here's the two second crash course in using the library. Given a CSV file with this content:

John Doe,50000
Jane Doe,60000

here's how you'd process it record-by-record:

{-# LANGUAGE ScopedTypeVariables #-}

import qualified Data.ByteString.Lazy as BL
import Data.Csv
import qualified Data.Vector as V

main :: IO ()
main = do
    csvData <- BL.readFile "salaries.csv"
    case decode NoHeader csvData of
        Left err -> putStrLn err
        Right v -> V.forM_ v $ \ (name, salary :: Int) ->
            putStrLn $ name ++ " earns " ++ show salary ++ " dollars"

If you want to parse a file that includes a header, like this one

name,salary
John Doe,50000
Jane Doe,60000

use decodeByName:

{-# LANGUAGE OverloadedStrings #-}

import Control.Applicative
import qualified Data.ByteString.Lazy as BL
import Data.Csv
import qualified Data.Vector as V

data Person = Person
    { name   :: !String
    , salary :: !Int
    }

instance FromNamedRecord Person where
    parseNamedRecord r = Person <$> r .: "name" <*> r .: "salary"

main :: IO ()
main = do
    csvData <- BL.readFile "salaries.csv"
    case decodeByName csvData of
        Left err -> putStrLn err
        Right (_, v) -> V.forM_ v $ \ p ->
            putStrLn $ name p ++ " earns " ++ show (salary p) ++ " dollars"

You can find more code examples in the examples/ folder as well as smaller usage examples in the Data.Csv module documentation.

Project Goals for cassava

There's no end to what people consider CSV data. Most programs don't follow RFC4180 so one has to make a judgment call which contributions to accept. Consequently, not everything gets accepted, because then we'd end up with a (slow) general purpose parsing library. There are plenty of those. The goal is to roughly accept what the Python csv module accepts.

The Python csv module (which is implemented in C) is also considered the base-line for performance. Adding options (e.g. the above mentioned parsing "flexibility") will have to be a trade off against performance. There's been complaints about performance in the past, therefore, if in doubt performance wins over features.

Last but not least, it's important to keep the dependency footprint light, as each additional dependency incurs costs and risks in terms of additional maintenance overhead and loss of flexibility. So adding a new package dependency should only be done if that dependency is known to be a reliable package and there's a clear benefit which outweights the cost.

Further reading

The primary API documentation for cassava is its Haddock documentation which can be found at http://hackage.haskell.org/package/cassava/docs/Data-Csv.html

Below are listed additional recommended third-party blogposts and tutorials

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].