fast-csv is a robust and high-performance CSV parser and writer library for Node.js, designed to handle large datasets efficiently. The current stable version is 5.0.5. It generally maintains a steady release cadence, with minor updates and bug fixes appearing every few months, and major versions released less frequently, typically when significant API changes or new features warrant it. Key differentiators include its streaming API, which allows for processing CSV data without buffering the entire file into memory, making it suitable for very large files. It supports both parsing (reading) and formatting (writing) CSV data, offering flexible configuration options for headers, delimiters, quotes, and escape characters, and ships with full TypeScript type definitions.
npm install fast-csvVerified import paths — ran on the pinned version, not inferred.
Demonstrates reading a CSV file, modifying its content, and then writing the modified data to a new CSV file using streaming APIs.
Ensure `@types/node` is installed as a dev dependency (`npm install --save-dev @types/node`) if you are using TypeScript and targeting Node.js APIs directly in your project.
Always explicitly set the `headers` option in `parseFile` or `parseStream` to `true` if your CSV has headers and you want object-based rows, or to `false` if you expect array-based rows.
Always include an `.on('error', errorHandler)` listener in your parsing and formatting pipelines to gracefully handle issues like file read errors, invalid CSV formats, or write errors.For precise control over quoting, refer to the `quote` and `quoteColumns` options in the `FormatterOptions`. If you want to force quoting for all fields, you might need a custom transform or specific formatter configuration.
Ensure the `format()` function returns a writable stream, usually by providing an array of data. When writing to a file, ensure `fs.createWriteStream()` is correctly called and that the `format` function is called with the data to be written.
Add an `.on('error', (err) => console.error(err))` listener to your `parseFile`, `parseStream`, `format`, or `pipe` chain to catch and handle errors gracefully.Check the official documentation or type definitions (`.d.ts` files) for the correct named exports. For example, `format` is a named export, not `formatDefault` or a default export.
No dependency data recorded yet.