node-csvreader
CSV file reader for NodeJS
Installation
From command line, npm
npm install csvreader
From command line, GitHub
Specific version:
npm install https://github.com/ysden123/node-csvreader.git#v0.0.1 --save
Last version:
npm install https://github.com/ysden123/node-csvreader.git --save
Dependencies in the package.json file
From npm
"csvreader": ""
From git
Specific version:
"csvreader": "git+https://github.com/ysden123/node-csvreader.git#v0.0.1"
Last version:
"csvreader": "git+https://github.com/ysden123/node-csvreader.git"
Usage
Function read
has arguments:
- csvFileName - the name of the CSV file
- recordHandler - function with 1 argument - array of record items
- options - optional, specifies addition requirements.
Object options
has properties (all properties are optional):
- skip - specifies number of lines to skip
- hasHeaders - true, if CSV file has headers; false, if CSV file has not headers. If true, then line with headers will be ignored
- headerRecordHandler - function with 1 argument - array of header items
- parseOptions - object, specifies options for parser, see (http://csv.adaltas.com/parse/)
Read all lines, no headers
var csvReader = ; { console;} csvReader ;
Skip 5 lines, no headers
var csvReader = ; { console;} var options = skip: 5; csvReader ;
Read all lines, 1st line is headers, handle headers
var csvReader = ; { console;} { console;} var options = skip: 5 hasHeaders: true headerRecordHandler: headerLineHandler; csvReader ;
Read all lines, no headers, delimiter is tabulator
var csvReader = ; { console;} var options = parseOptions: delimiter: '\t' csvReader ;
Change log
V1.0.3
Fixed version of the csv dependency: 1.1.1
V1.0.2
README was corrected.
V1.0.1
Fixed version number in package.json file.
V1.0.0
Parse options were added.
Dependencies
CSVReader uses package csv (https://github.com/wdavidw/node-csv)