0.2.1 • Published 12 years ago
csv-iterator v0.2.1
A ligthweight async csv-iterator for Node.js.
Example that creates an iterator from a file to iterate over rows 10 to 20:
var csvIterator = require('csv-iterator')
var iterator = csvIterator.fromFile('input.csv', {from: 10, to: 20})
The resulting iterator can be used with the async-iterators module to apply transformations or write to a target.
##Documentation ###fromLineIterator(lineIterator, options) Options:
toObjects
: transform the rows from arrays to objects according to the csv headerfrom
: start iteration on the specified row index (index is inclusive)to
: end iteration on the specified row index (index is inclusive)
###fromFile(path, options)
Same options as fromLineIterator
.
###toLines(iterator, options) Creates an iterator that transforms arrays or objects to CSV formatted lines.
Options:
objects
(default:false
): defines whether the source iterator returns arrays or objectscolumns
(optional): Ifobjects: true
this option will configure the columns that are output.
###toFile(iterator, path, options, cb)
Convenience function that uses toLines
to write directly to a file.
Options:
- same as
toCSV
options encoding
(defaultutf8
)