New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

batch-stream-csv

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

batch-stream-csv

Process large CSV files in batches without backpressure

  • 1.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Travis CI dependencies Status Coverage Status js-standard-style

batch-stream-csv

Process large CSV files in batches without backpressure

The CSV is streamed in batches and the stream is paused while you perform async operations on each batch to prevent backpressure building up

Uses csv-parser under the hood

Install

$ npm install batch-stream-csv

Usage:

const batch = require('batch-stream-csv');

batch('./file.csv', batchHandler, options).then(() => console.log('All done!'))

async function batchHandler (batch, progress) => {
  console.log(batch) // batch of rows parsed as JSON, e.g. [{ a: 1, b: 2 }, {  a: 2, b: 3 }]

  await db.batchInsert('table', batch) // the stream is paused while you do your inserts

  console.log(`${progress * 100}% complete`) // progress value can be fed into a progress bar
}

API:

Options:

  • batchSize: number of rows to process per batch (default = 5000)
  • ...see https://github.com/mafintosh/ for other options

FAQs

Package last updated on 13 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc