View on GitHub

Node-csv2json

A stream object that reads csv and writes json

Download this project as a .zip file Download this project as a tar.gz file

csv2json = CSV to JSON Stream Parser

Stream csv data and convert to json data

Usage

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)

API

var csv2json = require('csv2json')


parameters

Array of column names for each row that will be set as the json keys

The column separator for your csv file

The row separator for you csv file

var parseRow = require('csv2json').parseRow;


Array of column names for each row that will be set as the json keys

The column separator for your csv file

example

example.js

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

License

MIT

Contribute

pull requests are welcome

Thanks