A CSV parser that supports different separators, quoted fields, and multiline values. The results are provided as lists.
{ headers : List String
, records : List (List String)
}
The Csv
type structure.
parseWith : Char -> String -> Csv
Parse the input string into a CSV Structure using a custom delimiter
parseWith '☃' "id☃value\n1☃one\n2☃two" =
{ headers = [ "id", "value" ]
, records =
[ [ "1", "one" ]
, [ "2", "two" ]
]
}
parse : String -> Csv
Parse the input string into a CSV Structure
parse "value\n\"Here is a multiline \nvalue - 1,2,3\"\nsingle line value" =
{ headers = [ "value" ]
, records =
[ [ "Here is a multiline \nvalue - 1,2,3" ]
, [ "single line value" ]
]
}