fast-csv
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@fast-csv/format | 4.3.5 | 10.64 kB | MIT | prod | |
@fast-csv/parse | 4.3.6 | 19.11 kB | MIT | prod |
Fast-CSV is an npm package that serves as a comprehensive CSV parser and writer. This package unifies the functionalities of @fast-csv/format
for formatting CSV files and @fast-csv/parse
designed for parsing CSV files, providing a single package that conveniently manages all things related to CSV files.
To employ Fast-CSV, you need to install the package, typically through npm using the command npm install --save fast-csv
. Once installed, you can use it in your script like:
const csv = require('fast-csv');
This module provides various utilities to parse or format CSV data. For example, to parse CSV data, you could use:
csv.parseString('a,b\na1,b1\na2,b2', {headers: true})
.on('data', row => console.log(row))
.on('end', rowCount => console.log(`Parsed ${rowCount} rows`));
You can use similar code to write data to a CSV file.
const dataRows = [
{a: 'a1', b: 'b1'},
{a: 'a2', b: 'b2'},
];
csv.writeToString(dataRows, {headers: true})
.then(csvString => console.log(csvString))
The official Fast-CSV documentation is hosted on C2FO's official website. You can access them using these links: