Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@fast-csv/parse
Advanced tools
@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.
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`));
csv-parser is a simple and fast CSV parsing library for Node.js. It is similar to @fast-csv/parse in terms of functionality but is often praised for its simplicity and ease of use. However, it may not offer as many advanced features and customization options as @fast-csv/parse.
PapaParse is a powerful CSV parsing library that works in both Node.js and the browser. It offers a wide range of features, including support for large files, web workers, and various parsing options. Compared to @fast-csv/parse, PapaParse is more versatile in terms of environment support but may have a steeper learning curve.
csv-parse is a part of the CSV module suite from the Node.js CSV project. It provides robust CSV parsing capabilities with a focus on performance and flexibility. While it offers similar functionality to @fast-csv/parse, it is part of a larger suite of CSV-related tools, which can be advantageous for more complex CSV handling needs.
@fast-csv/parse
fast-csv
package to parse CSVs.
To get started with @fast-csv/parse
check out the docs
FAQs
fast-csv parsing package
We found that @fast-csv/parse demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.