comma alternatives and similar packages
Based on the "Text" category.
Alternatively, view comma alternatives based on common mentions on social networks and blogs.
-
pandoc-citeproc
Library and executable for using citeproc with pandoc -
scholdoc
Fork of Pandoc for the implementation of a ScholarlyMarkdown parser -
blaze-from-html
A blazingly fast HTML combinator library for Haskell. -
prettyprinter
A modern, extensible and well-documented prettyprinter. -
skylighting
A Haskell syntax highlighting library with tokenizers derived from KDE syntax highlighting descriptions -
commonmark
Pure Haskell commonmark parsing library, designed to be flexible and extensible -
regex-genex
Given a list of regexes, generate all possible strings that matches all of them. -
regex-applicative
Regex-based parsing with an applicative interface -
pandoc-csv2table
A Pandoc filter that renders CSV as Pandoc Markdown Tables. -
servant-checked-exceptions
type-level errors for Servant APIs. -
double-conversion
A fast Haskell library for converting between double precision floating point numbers and text strings. It is implemented as a binding to the V8-derived C++ double-conversion library. -
text-format
A Haskell text formatting library optimized for ease of use and high performance. -
diagrams-pandoc
A pandoc filter to express diagrams inline using the haskell EDSL diagrams. -
boxes
A pretty-printing library for laying out text in two dimensions, using a simple box model.
Access the most powerful time series database as a service
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of comma or a related project?
README
Text.Comma
The comma
package implements parsing and producing of the CSV format.
Build & install
There are two standard ways of obtaining the module:
- by cloning the git repository:
git clone https://github.com/lovasko/comma
- by using the central Hackage server:
cabal install comma
Dependencies
Main part, the library itself, depends on two packages:
attoparsec
text
In addition, the testing component of the project depends on the QuickCheck
package.
API
The Text.Comma
module exports only two functions: comma
and uncomma
,
parsing and producing CSV respectively. The function prototypes are as follows:
-- | Parse a block of text into a CSV table.
comma :: T.Text -- ^ CSV text
-> Either String [[T.Text]] -- ^ error | table
-- | Render a table of texts into a valid CSV output.
uncomma :: [[T.Text]] -- ^ table
-> T.Text -- ^ CSV text
Example
The following example loads any CSV file and prepends a column that contains row numbers:
{-# LANGUAGE OverloadedStrings #-}
import Text.Comma
import System.Exit
import qualified Data.Text as T
import qualified Data.Text.IO as T
-- | Prepend a number in front of each row.
number :: [[T.Text]] -> [[T.Text]]
number = zipWith (:) (map (T.pack . show) [0..])
main :: IO ()
main = T.readFile "table.csv" >>= (\file -> case comma file of
Left err -> T.putStrLn ("ERROR: " <> T.pack err) >> exitFailure
Right csv -> T.writeFile "table.csv" (uncomma $ number csv) >> exitSuccess)
Example usage:
$ cat table.csv
name,surname,language
Dennis,Ritchie,C
Larry,Wall,Perl
John,McCarthy,Lisp
$ ./number && cat table.csv
0,name,surname,language
1,Dennis,Ritchie,C
2,Larry,Wall,Perl
3,John,McCarthy,Lisp
Standards
Both producing and parsing of CSV files closely follows the
RFC4180 document. The comma
implementation has made the following decisions:
- record separator is always only
\n
('\r` is not recognized as a newline symbol) - it is not required for the last record to be trailed with a
\n
. This means thatcomma "hello\nworld" == comma "hello\nworld\n" == Right [["hello"], ["world"]]
License
The comma
package is licensed under the terms of the [2-clause BSD
license](LICENSE). In case you need any other license, feel free to contact the
author.
Author
Daniel Lovasko [email protected]
*Note that all licence references and agreements mentioned in the comma README section above
are relevant to that project's source code only.