sv: Encode and decode separated values (CSV, PSV, ...)
sv (separated values) is a library for parsing, decoding, encoding, and printing CSV and similar formats (such as PSV, TSV, and many more).
sv uses an Applicative combinator style for decoding and encoding, rather than a type class based approach. This means we can have multiple decoders for the same type, multiple combinators of the same type, and we never have to worry about orphan instances. These decoders can be stitched together from provided primitives and combinators, or you can build one from a parser from your favourite parser combinator library.
For parsing, sv uses hw-dsv, a high performance streaming CSV parser based on rank-select data structures. sv works with UTF-8, and should work with CP-1252 as well. It does not work with UTF-16 or UTF-32.
sv returns values for all errors that occur - not just the first. Errors have more structure than just a string, indicating what went wrong.
sv tries not to be opinionated about how your data should look. We intend for the user to have a great degree of freedom to build the right decoder for their dataset.
Parts of sv are intended to be imported as follows:
import Data.Sv import qualified Data.Sv.Decode as D import qualified Data.Sv.Encode as E
Examples:
Decoding a real CSV: Species.lhs
Decoding by column name: Columnar.hs
Encoding data to a CSV: Encoding.hs
Encoding data to a CSV with a header: EncodingWithHeader.hs
Handling NULL and Unknown occuring in a column of numbers: Numbers.hs
Dealing with non-rectangular data: Ragged.hs
Integrating with an existing attoparsec parser to read date stamps: TableTennis.hs
To get the best performance, the hw-dsv parser and its dependencies
underlying sv should be compiled with the flag +bmi2
to enable . These
libraries are: bits-extra
, hw-rankselect
, hw-rankselect-base
, and
hw-dsv
. A simple way to set the flags for all of them when building with
cabal is to include a cabal.project file in your project containing
something like the following:
packages: . package bits-extra flags: +bmi2 package hw-rankselect flags: +bmi2 package hw-rankselect-base flags: +bmi2 package hw-dsv flags: +bmi2
Downloads
- sv-1.4.0.1.tar.gz [browse] (Cabal source package)
- Package description (as included in the package)
Maintainer's Corner
For package maintainers and hackage trustees
Candidates
Versions [RSS] | 0.1, 1.0, 1.1, 1.1.1, 1.2, 1.3, 1.3.0.1, 1.3.1, 1.4, 1.4.0.1 |
---|---|
Change log | changelog.md |
Dependencies | attoparsec (>=0.12.1.4 && <0.14), base (>=4.9 && <4.15), bifunctors (>=5.1 && <5.6), bytestring (>=0.9.1.10 && <0.11), contravariant (>=1.2 && <1.6), hw-dsv (>=0.4 && <0.5), semigroupoids (>=5 && <5.4), sv-core (>=0.5 && <0.6), transformers (>=0.2 && <0.6), utf8-string (>=1 && <1.1), validation (>=1 && <1.2) [details] |
Tested with | ghc ==8.0.2, ghc ==8.2.2, ghc ==8.4.4, ghc ==8.6.5, ghc ==8.8.3, ghc ==8.10.1 |
License | BSD-3-Clause |
Copyright | Copyright (c) 2017-2019, Commonwealth Scientific and Industrial Research Organisation (CSIRO) ABN 41 687 119 230. |
Author | George Wilson |
Maintainer | george@qfpl.io |
Category | CSV, Text, Web |
Home page | https://github.com/qfpl/sv |
Bug tracker | https://github.com/qfpl/sv/issues |
Source repo | head: git clone git@github.com/qfpl/sv.git |
Uploaded | by GeorgeWilson at 2020-04-26T03:49:10Z |
Distributions | |
Reverse Dependencies | 3 direct, 0 indirect [details] |
Downloads | 4981 total (22 in the last 30 days) |
Rating | (no votes yet) [estimated by Bayesian average] |
Your Rating | |
Status | Docs available [build log] Last success reported on 2020-04-26 [all 1 reports] |