A CSV parser that supports different separators, and quoted fields. The results are provided as lists.
Convert a string of values separated by a separator into a Csv structure.
>>> parseWith ";" "id;value\n1;one\n2;two\n"
{
headers = ["id", "value"],
records = [
["1", "one"],
["2", "two"]
]
}Convert a string of comma-separated values into a Csv structure.
>>> parse "id,value\n1,one\n2,two\n"
{
headers = ["id", "value"],
records = [
["1", "one"],
["2", "two"]
]
}Values that contain the character ',' can be quoted
>>> parse "id,value\n\"1,2,3\",\"one,two,three\"\n"
{
headers = ["id", "value"],
records = [
["1,2,3", "one,two,three"]
]
}Double quotes can be escaped with a backslash or a second quote
>>> parse "value\n,Here is a quote:\"\"\nAnother one:\\\"\n"
{
headers = ["value"],
records = [
["Here is a quote:\""],
["Another one:\""]
]
}Convert a string of comma-separated values into a list of lists.
>>> split "id,value\n1,one\n2,two\n"
[["id", "value"], ["1", "one"], ["2", "two"]]Convert a string of values separated by a character into a list of lists.
>>> splitWith "," "id,value\n1,one\n2,two\n"
[["id", "value"], ["1", "one"], ["2", "two"]]
The
Csvtype structure.