A stream object that reads csv and writes json
CoffeeScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.gitignore
Cakefile
index.js
package.json
readme.md

readme.md

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

  • 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

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


  • 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

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