Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

hubgit/input-stream

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

input-stream

Install

npm install --save input-stream

or

yarn add input-stream

Formats

The input stream functions as an async iterator, so each item can be awaited in a for loop.

CSV

const input = require('input-stream')('data/example.csv')

for await (const item of input) {
  console.log(item)
}

Options provided as a second parameter will be passed through to csv-parser.

TSV

const input = require('input-stream')('data/example.tsv')

for await (const item of input) {
  console.log(item)
}

Options provided as a second parameter will be passed through to csv-parser, apart from separator.

NDJSON

const input = require('input-stream')('data/example.ndjson')

for await (const item of input) {
  console.log(item)
}

XML

const input = require('input-stream')('data/example.xml', {
  element: 'foo'
})

for await (const item of input) {
  console.log(item)
}

Options provided as a second parameter will be passed through to xml-stream, apart from output.

Piping to an output stream

An example of piping the input stream directly to output-stream, for conversion between formats.

const input = require('input-stream')('data/example.csv')
const output = require('output-stream')('data/example.ndjson')

input.pipe(output)

About

Read data from a CSV or NDJSON file to a stream

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.