Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

49 lines (31 sloc) 1.125 kB

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
Jump to Line
Something went wrong with that request. Please try again.