csv-simple-stream

0.4.0 • Public • Published

csv-simple-stream

Build Status

NPM

A ligthweight simple-stream transform for parsing a character stream.

Example that creates a csv stream from a file and print rows 10 to 20:

var csvStream = require('csv-simple-stream')
var streamUtils = require('simple-stream')
 
var stream = csvStream.fromFile('input.csv', {from: 10, to: 20})
streamUtils.forEach(stream, console.log)

The resulting simple-stream can be used with the simple-stream module to apply transformations or write to a sink.

Documentation

fromLines(lineStream, [options]) -> stream

Options:

  • toObjects: transform the rows from arrays to objects according to the csv header
  • from: start iteration on the specified row index (index is inclusive)
  • to: end iteration on the specified row index (index is inclusive)

fromFile(path, options) -> stream

Same options as fromLines.

toLines(dataStream, options) -> stream

Creates a stream that transforms arrays or objects to CSV formatted lines.

Options:

  • objects (default: false): defines whether the source iterator returns arrays or objects
  • columns (optional): If objects: true this option will configure the columns that are output.

toFile(dataStream, path, [options]) -> continuable

Convenience function that uses toLines to write directly to a file.

Options:

  • same as toCSV options
  • encoding (default utf8)

Readme

Keywords

none

Package Sidebar

Install

npm i csv-simple-stream

Weekly Downloads

2

Version

0.4.0

License

BSD

Last publish

Collaborators

  • mirkok