csv-iterator
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 =var iterator = csvIterator
The resulting iterator can be used with the async-iterators module to apply transformations or write to a target.
Documentation
fromLines(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
)