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

@fast-csv/parse

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fast-csv/parse

fast-csv parsing package

  • 4.3.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
803K
decreased by-61.13%
Maintainers
1
Weekly downloads
 
Created

What is @fast-csv/parse?

@fast-csv/parse is a powerful and flexible CSV parsing library for Node.js. It allows you to read and parse CSV files or strings with ease, providing a variety of options to handle different CSV formats and use cases.

What are @fast-csv/parse's main functionalities?

Parsing CSV from a file

This feature allows you to parse a CSV file from the file system. The `headers: true` option indicates that the first row of the CSV file contains headers.

const fs = require('fs');
const { parse } = require('@fast-csv/parse');

fs.createReadStream('path/to/your.csv')
  .pipe(parse({ headers: true }))
  .on('data', row => console.log(row))
  .on('end', rowCount => console.log(`Parsed ${rowCount} rows`));

Parsing CSV from a string

This feature allows you to parse a CSV string directly. The `headers: true` option indicates that the first row of the CSV string contains headers.

const { parseString } = require('@fast-csv/parse');

const csvString = 'header1,header2\nvalue1,value2\nvalue3,value4';

parseString(csvString, { headers: true })
  .on('data', row => console.log(row))
  .on('end', rowCount => console.log(`Parsed ${rowCount} rows`));

Handling different delimiters

This feature allows you to parse CSV data with a custom delimiter. In this example, the delimiter is set to a semicolon (`;`).

const { parseString } = require('@fast-csv/parse');

const csvString = 'header1;header2\nvalue1;value2\nvalue3;value4';

parseString(csvString, { headers: true, delimiter: ';' })
  .on('data', row => console.log(row))
  .on('end', rowCount => console.log(`Parsed ${rowCount} rows`));

Transforming data during parsing

This feature allows you to transform data during parsing. The `transform` function is applied to each row, allowing you to modify the data as it is being parsed.

const { parse } = require('@fast-csv/parse');

const transform = (row) => {
  return {
    ...row,
    transformed: true
  };
};

parse({ headers: true, transform })
  .on('data', row => console.log(row))
  .on('end', rowCount => console.log(`Parsed ${rowCount} rows`));

Other packages similar to @fast-csv/parse

Keywords

FAQs

Package last updated on 02 Sep 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