Registry / data / neat-csv

neat-csv

JSON →
library7.0.0jsnpmunverified

neat-csv is a lightweight, promise-based wrapper around the high-performance streaming `csv-parser` module, designed for quickly parsing CSV data from strings, buffers, or readable streams into an array of JavaScript objects. The current stable version is 7.0.0. While `csv-parser` focuses on stream-based processing, `neat-csv` offers a convenient, promise-returning API, making it ideal for scenarios where the entire CSV content is available upfront or can be easily buffered. Its release cadence is tied to updates in Node.js compatibility and significant changes in its underlying `csv-parser` dependency. A key differentiator is its straightforward API for non-streaming use cases, abstracting away stream handling complexities while retaining the performance benefits of its core parser. Since version 7.0.0, the package is pure ESM, requiring modern Node.js environments and import syntax.

npm install neat-csv
INSTALL
IMPORT
SIG · NEAT-CSV
N
neat-csv
datajavascriptv7.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

neatCsv
import neatCsv from 'neat-csv';
const neatCsv = require('neat-csv');
Since v7.0.0, neat-csv is a pure ESM package. CommonJS `require()` is no longer supported.
Options
import type { Options } from 'neat-csv';
import { Options } from 'neat-csv';
The `Options` type defines the configuration object for parsing, matching `csv-parser`'s options. Use `import type` to ensure it's a type-only import and avoids potential runtime issues.

Demonstrates parsing CSV data from strings, buffers, and Node.js readable streams, including passing options for custom delimiters.

import neatCsv from 'neat-csv'; import { Readable } from 'node:stream'; async function runParsingExamples() { // Example 1: Parsing a simple CSV string const csvString = 'header1,header2\nvalueA1,valueA2\nvalueB1,valueB2'; console.log('--- Parsing from string ---'); console.log(await neatCsv(csvString)); // Expected: [{ header1: 'valueA1', header2: 'valueA2' }, { header1: 'valueB1', header2: 'valueB2' }] // Example 2: Parsing a CSV buffer const csvBuffer = Buffer.from('name,age\nAlice,30\nBob,24'); console.log('\n--- Parsing from buffer ---'); console.log(await neatCsv(csvBuffer)); // Expected: [{ name: 'Alice', age: '30' }, { name: 'Bob', age: '24' }] // Example 3: Parsing a CSV from a Readable stream const streamData = ['product,price', 'Laptop,1200', 'Mouse,25'].join('\n'); const csvStream = Readable.from(streamData); console.log('\n--- Parsing from stream ---'); console.log(await neatCsv(csvStream)); // Expected: [{ product: 'Laptop', price: '1200' }, { product: 'Mouse', price: '25' }] // Example 4: Using options (e.g., custom delimiter) - neat-csv passes options directly to csv-parser const tsvString = 'id\tlabel\n1\tItem A\n2\tItem B'; console.log('\n--- Parsing TSV with delimiter option ---'); console.log(await neatCsv(tsvString, { separator: '\t' })); // Expected: [{ id: '1', label: 'Item A' }, { id: '2', label: 'Item B' }] } runParsingExamples().catch(console.error);
Debug
Known issues
breakingVersion 7.0.0 and newer are pure ESM (ECMAScript Modules). CommonJS `require()` is no longer supported. Projects must be configured for ESM or use an older version of the package.
fix
Migrate your project to use ES modules (`"type": "module"` in `package.json` or `.mjs` files) and use `import neatCsv from 'neat-csv';`.
affects: >=7.0.0
breakingNode.js 12.20.0 or higher is required for version 7.0.0. Ensure your Node.js environment meets this minimum requirement.
fix
Upgrade your Node.js runtime to version 12.20.0, 14.13.1, 16.0.0, or newer.
affects: >=7.0.0
breakingNode.js 10 or higher is required for version 6.0.0. Older Node.js versions are not supported.
fix
Upgrade your Node.js runtime to version 10 or newer.
affects: >=6.0.0 <7.0.0
gotchaParsing-related issues, such as incorrect data interpretation or parsing errors, should primarily be reported to the upstream `csv-parser` package, as `neat-csv` acts as a thin wrapper.
fix
Before opening an issue for `neat-csv`, check the `csv-parser` repository for existing issues or report it there if it's a core parsing problem.
affects: >=5.0.0
deprecatedThe `Row` TypeScript return type was made generic in v5.2.0. Older versions might not fully support specific row typing.
fix
Upgrade to `neat-csv` v5.2.0 or newer to take full advantage of generic TypeScript row typing.
affects: <5.2.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Attempting to use `require()` to import `neat-csv` in a CommonJS module after version 7.0.0.
fix
Switch to ES module import syntax: `import neatCsv from 'neat-csv';` and ensure your project is configured for ESM.
TypeError: neatCsv is not a function
This usually indicates an incorrect import statement (e.g., trying to named import a default export) or a Node.js version incompatibility preventing the module from loading correctly.
fix
Ensure you are using `import neatCsv from 'neat-csv';` for ESM projects and that your Node.js version meets the package requirements.
Uncaught SyntaxError: Cannot use 'import' statement outside a module
Attempting to use `import` syntax in a Node.js environment that is treating the file as CommonJS (e.g., missing `"type": "module"` in `package.json` or not using `.mjs` extension).
fix
Add `"type": "module"` to your `package.json` file or rename your file to `.mjs` to explicitly declare it as an ES module.
Upgrade
Version history
7.0.0latest on npm
Audit
Dependencies
csv-parserrequiredneat-csv is a convenience wrapper around this core CSV streaming parser; parsing-related issues are often rooted here.
Agent activity
4 hits · last 30 days
node
4
Resources
neat-csv — npm install neat-csv · libregistry