Socket
Socket
Sign inDemoInstall

fast-csv

Package Overview
Dependencies
10
Maintainers
3
Versions
73
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    fast-csv

CSV parser and writer


Version published
Weekly downloads
1.4M
decreased by-17.36%
Maintainers
3
Install size
298 kB
Created
Weekly downloads
 

Package description

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

Changelog

Source

5.0.1 (2024-02-13)

Note: Version bump only for package fast-csv

Readme

Source

fast-csv Logo

npm version Build Status Coverage Status Known Vulnerabilities

fast-csv

Package that combines both @fast-csv/format and @fast-csv/parse into a single package.

Installation

Install Guide

Usage

To get started with fast-csv check out the docs

Keywords

FAQs

Last updated on 13 Feb 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc