A CSV (comma-separated values) parser written in JavaScript.
Originally part of Christopher Parker's CSV to JSON converter. Because of this, some feature requests, bug reports, etc. may be filed there, instead. Before opening a new issue here, please make sure it doesn't already exist there.
Prerequisites:
After cloning this repo, here's how to build:
$ npm install
$ grunt
This will download all dependencies, lint, test, and minify the library.
The minified library resides at dist/csv.min.js
.
Basic example:
var CSV = require('csv-js'),
input = 'foo, bar, baz\n1, 2, 3',
output;
try {
output = CSV.parse(input);
console.dir(output);
} catch (e) {}
The output array will be inspected by console.dir
and the following will be printed to stdout:
[
{
"foo": "1",
"bar": "2",
"baz": "3"
}
]