sv

Encode and decode separated values (CSV, PSV, ...)

https://github.com/qfpl/sv

Version on this page:1.3.1@rev:2
LTS Haskell 14.27:1.3.1@rev:2
Stackage Nightly 2019-09-21:1.4@rev:1
Latest on Hackage:1.4.0.1

See all snapshots sv appears in

BSD-3-Clause licensed by George Wilson
Maintained by [email protected]
This version can be pinned in stack with:sv-1.3.1@sha256:eabf6b128e25b7ad23905742723117bf5050fe76a858c92c95b5fdbb400018b0,7185

Module documentation for 1.3.1

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:

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

Changes

Revision history for sv

1.3.1 – 2019-04-02

  • Update to sv-core 0.4.1

1.3.0.1 – 2019-02-26

  • Fix an occasionally failing property-test

1.3 – 2019-01-14

  • Update to sv-core 0.4

1.2 – 2018-09-26

  • Update to sv-core 0.3

1.1.1 – 2018-08-10

  • Depend on sv-core 0.2.1 to get column-name-based encoding

1.1 – 2018-07-25

  • Add column-name-based decoding by adding parseDecodeNamed and associated functions
  • Support sv-core 0.2

1.0 – 2018-07-19

  • Split the package into sv, sv-core, svfactor. This removes Data.Sv.{Parse,Print,Syntax} and changes types in Data.Sv.Decode and Data.Sv.Encode. Compatibility with version 0.1 is minimal

0.1 – 2018-03-06

  • First version. Released on an unsuspecting world.