Yet another CSV parser that you may want.

Features

  • Tolerant quate escaping.
  • Streaming conversion for very large files.

Motivation

Have you ever seen a CSV like this:

x                              ,y
   "  an"  "escaped"(string)   ,ok

Be attention the white space trimming and continuations of quote escaping.

Most RFC4180 compliant CSV parsers fails to parse this.

But these data are so many in the wild where I live. So I made this library.

We can parse this to:

[
  {
    "x": "  an  escaped(string)",
    "y": "ok"
  }
]

Usage

const input = 'a,b,c\n1,2,3';
print(parseCsv(input));
>>> [['a', 'b', 'c'], ['1', '2', '3']]
print(parseCsvAsMap(input));
>>> [{'a': '1', 'b': '2', 'c': '3'}]

Libraries

csv_ya
Yet another CSV parser that you may want.