csv1

CSV-JS - A Comma-Separated Values parser for JS

Built to rfc4180 standard, with options for adjusting strictness:

  • optional carriage returns for non-microsoft sources
  • automatically type-cast numeric an boolean values
  • relaxed mode which: ignores blank lines, ignores gargabe following quoted tokens, does not enforce a consistent record length

Adopted for UnityBase by pavel.mash

Usage sample:

  var CSV = require('csv1');
  // simple
  var rows = CSV.parse('one,two,three\nfour,five,six')
  // rows equals [["one","two","three"],["four","five","six"]]
  // or read from file system
  var fs = require('fs'), f = fs.readFileSync('c:/csv.txt');
  var rows = CSV.parse(f);
  for( var i =0; i < rows.length; i++){
     console.log(rows[i]);
  }

Methods

parse(str, commaopt)Array inner

rfc4180 standard csv parse with options for strictness and data type conversion By default, will automatically type-cast numeric an boolean values.
Arguments:
  1. str (String)  A CSV string
  2. [comma=";"] (String)  column separator