All Projects → twilson63 → node-csv2json

twilson63 / node-csv2json

Licence: other
A stream object that reads csv and writes json

Programming Languages

coffeescript
4710 projects

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].