/tiny-csv

Parse a CSV string into an array of objects.

Primary LanguageJavaScriptMIT LicenseMIT

tiny-csv

NPM version License Build status

Parse a CSV string into an array of objects.

Installation

npm install tiny-csv

Usage

var fs  = require('fs')
var csv = require('tiny-csv')

var csvData = fs.readFileSync('data.csv', 'utf8')
console.log(csv(csvData))
// [
//   { key: 'one', value: 'two' },
//   { key: 'three', value: 'four' },
//   { key: 'five', value: 'six' }
// ]

var tsvData = fs.readFileSync('data.tsv', 'utf8')
console.log(csv(tsvData, /\t/))
// [
//   { key: 'one', value: 'two' },
//   { key: 'three', value: 'four' },
//   { key: 'five', value: 'six' }
// ]

Caveats

The module is meant to be used on smaller sets of data. If you need maximum speed, use csv-parser.