samuelstevens/elm-csv

Parse CSV files according to RFC 4180


Keywords
csv, elm
License
BSD-3-Clause
Install
elm-package install samuelstevens/elm-csv 1.0.1

Documentation

elm-csv

Parse CSV files according to RFC 4180 (including values with quoted commas).

Install

elm install samuelstevens/elm-csv

Quick Start

Suppose you have a file star-wars-quotes.csv with the following content:

quote,character
"Why, hello there",Obi-Wan Kenobi
"General Kenobi.",General Grievous

Once this is read into an Elm string, you could parse it like this:

import Csv

let
  content = 
    "quote,character\n\"Why, hello there\",Obi-Wan Kenobi\n\"General Kenobi.\",General Grievous"
in
Csv.parseRows content --> Ok [[ "quote", "character"],["Why, hello there", "Obi-Wan Kenobi"],["General Kenobi.", "General Grievous"]]

Calling Csv.parseCsv will produce a list of lists of strings, properly escaped from their CSV representation.