Stream csv data and convert to json data
var csv2json = require('csv2json'),
columns = ['foo','bar','baz'];
process.openStdin().pipe(csv2json(columns).pipe(process.stdout));
csv2json = require 'csv2json'
columns = ['foo','bar','baz']
process.openStdin().pipe csv2json(columns).pipe(process.stdout)
- columns
Array of column names for each row that will be set as the json keys
- columnSeparator (default ',')
The column separator for your csv file
- rowSeparator (default '\n')
The row separator for you csv file
- columns
Array of column names for each row that will be set as the json keys
- columnSeparator (default ',')
The column separator for your csv file
example
var es = require('event-stream'),
parseRow = require('csv2json').parseRow;
es.pipe(
es.openStdin(),
es.split(),
parseRow(['foo','bar','baz']),
es.join(','),
process.stdout
);
echo "'baz','bar','foo'" | node example.js
MIT
pull requests are welcome