0.0.3 • Published 11 years ago

columnist v0.0.3

Weekly downloads
2
License
-
Repository
github
Last release
11 years ago

Columnist

Build Status

A node module for parsing out csv documents to an array of object literals as well as attempts to parse data into the numbers when possible

Example

test.csv

"brandon", 'farmer', 30, 3.5
john, smith, 45, 4.0
tom, jones, 65, 2.5

JS file

var Columnist = require('columnist');
var data = require('fs').readFileSync('./test.csv', 'utf8');

var columnist = new Columnist(['first', 'last', 'age', 'gpa'], { /* options */ });

console.log(columnist.parse(data));

This example will result in the following array.

[ { first: 'brandon', last: 'farmer', age: 30, gpa: 3.5 },
  { first: 'john', last: 'smith', age: 45, gpa: 4 },
  { first: 'tom', last: 'jones', age: 65, gpa: 2.5 } ]

Options

  • ignore_first -- (default: false) will ignore the first line of the document
  • ignore_last -- (default: false) will ignore the last line of the document
  • remove_quotes -- (default: true) remove quotes from document