Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fast-csv

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-csv

CSV parser for node.js

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6M
decreased by-24.97%
Maintainers
1
Weekly downloads
 
Created

What is fast-csv?

The fast-csv npm package is a comprehensive library for working with CSV data in Node.js. It provides functionalities for parsing CSV files and strings, formatting data to CSV, and transforming data during the parse and format process.

What are fast-csv's main functionalities?

Parsing CSV

This feature allows you to parse CSV files or strings. The code sample demonstrates how to read a CSV file using a stream, parse it with headers, and log each row to the console.

const fs = require('fs');
const fastcsv = require('fast-csv');

fs.createReadStream('data.csv')
  .pipe(fastcsv.parse({ headers: true }))
  .on('data', row => console.log(row))
  .on('end', () => console.log('CSV file successfully processed'));

Formatting Data to CSV

This feature allows you to format JavaScript data arrays or streams to CSV. The code sample shows how to take an array of objects and write it to a CSV file with headers.

const fs = require('fs');
const fastcsv = require('fast-csv');

const data = [{ id: 1, name: 'John Doe' }, { id: 2, name: 'Jane Doe' }];

fastcsv
  .write(data, { headers: true })
  .pipe(fs.createWriteStream('out.csv'))
  .on('finish', () => console.log('Write to out.csv successfully!'));

Transforming Data

This feature allows you to transform data during the parse or format process. The code sample demonstrates how to read a CSV file, transform each row by combining first and last names into a full name, and then write the transformed data to a new CSV file.

const fs = require('fs');
const fastcsv = require('fast-csv');

fs.createReadStream('data.csv')
  .pipe(fastcsv.parse({ headers: true }))
  .transform(row => ({ fullName: row.firstName + ' ' + row.lastName }))
  .pipe(fastcsv.format({ headers: true }))
  .pipe(fs.createWriteStream('out.csv'))
  .on('finish', () => console.log('Transformed file successfully written.'));

Other packages similar to fast-csv

Keywords

FAQs

Package last updated on 08 Oct 2013

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