Registry / data / incremental-csv-parser

incremental-csv-parser

JSON →
library1.1.1jsnpmunverified

Incremental CSV Parser is a fast, lightweight, and dependency-free library for parsing Comma Separated Values (CSV) data in both browser and Node.js environments. It currently stands at stable version 1.1.1, with recent updates (like v1.1.0 adding `.headers()`) indicating active maintenance, though a strict release cadence is not specified. Key differentiators include its incremental parsing API, full compliance with RFC4180, and minimal footprint due to zero external dependencies. A crucial aspect of its design is that all parsed column values are returned as strings, meaning it does not automatically parse numbers, dates, or other data types, requiring explicit conversion by the consumer. It provides both ESM and CJS builds and ships with TypeScript type definitions for enhanced developer experience.

npm install incremental-csv-parser
INSTALL
IMPORT
SIG · INCREMENTAL-CSV-PA
I
incremental-csv-parser
datajavascriptv1.1.1
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.

parse
import { parse } from 'incremental-csv-parser';
const { parse } = require('incremental-csv-parser');
Use for parsing an entire CSV string at once. While a CJS build is provided, modern usage prefers ESM imports.
CSVParser
import { CSVParser } from 'incremental-csv-parser';
const { CSVParser } = require('incremental-csv-parser');
This class enables incremental parsing of CSV data, processing chunks as they arrive. Modern usage prefers ESM imports.
CSVParser (with generics)
import { CSVParser } from 'incremental-csv-parser'; type MyColumns = 'id' | 'name'; const parser = new CSVParser<MyColumns>(row => console.log(row));
Leverage TypeScript generics to define expected column names and types, providing compile-time safety and better autocompletion for parsed rows.

Demonstrates how to use the `CSVParser` class for incremental processing of CSV data chunks, collecting parsed rows, and accessing headers.

import { CSVParser } from 'incremental-csv-parser'; // Simulating a readable stream or chunked data input const csvDataChunks = [ 'header1,header2,header3\n', 'valueA1,valueA2,valueA3\n', 'valueB1,valueB2,valueB3\n', 'valueC1,valueC2,valueC3\n', 'valueD1,valueD2,valueD3' // last chunk without a trailing newline ]; const parsedRows = []; const parser = new CSVParser((row) => { parsedRows.push(row); console.log('Parsed Row:', row); // Log each row as it's parsed }); console.log('Starting incremental CSV parsing...'); for (const chunk of csvDataChunks) { parser.process(chunk); } // After processing all chunks, call flush to ensure any buffered data is emitted parser.flush(); console.log('Incremental parsing complete. All rows:', parsedRows); // Verify the parsed headers from the latest version (v1.1.0) console.log('Parsed Headers (if available):', parser.headers());
Debug
Known issues
gotchaAll column values are strictly treated as strings. Numbers, dates, booleans, or other data types will not be automatically parsed or converted, requiring manual transformation post-parsing.
fix
Implement explicit type conversion logic for specific columns after receiving the parsed row objects (e.g., `parseInt(row.id, 10)`, `new Date(row.timestamp)`).
affects: >=1.0.0
gotchaAttempting to use `require()` for imports in an environment configured for ESM (e.g., Node.js with `"type": "module"` in `package.json`) can lead to module resolution errors or incorrect module loading.
fix
Prefer `import` statements (e.g., `import { parse } from 'incremental-csv-parser';`) in ESM projects. If strictly using CommonJS, ensure your environment correctly handles the CJS build.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: (0 , incremental_csv_parser__WEBPACK_IMPORTED_MODULE_0__.CSVParser) is not a constructor
Using `require()` syntax in an ESM context for a module that is primarily ESM-first or has conflicting module exports.
fix
Ensure your project uses `import { CSVParser } from 'incremental-csv-parser';` when operating in an ESM environment. If using CommonJS, verify correct `const { CSVParser } = require('incremental-csv-parser');` usage and project setup.
Property 'myColumn' does not exist on type '{ [key: string]: string; }'.
When using TypeScript, the parser defaults to `Record<string, string>` for row types. Direct property access (e.g., `row.myColumn`) will fail unless specific column types are provided.
fix
Define a union type for your column names (e.g., `type MyColumns = 'id' | 'name';`) and pass it as a generic to the parser: `new CSVParser<MyColumns>(...)` or `parse<MyColumns>(...)`.
Expected numerical values are returned as strings (e.g., '123' instead of 123).
The parser's design principle is to treat all CSV cell values as strings, adhering to its lightweight and no-automatic-conversion philosophy.
fix
After parsing, explicitly convert the string values to the desired data type using standard JavaScript functions like `Number()`, `parseInt()`, `parseFloat()`, or `new Date()`.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
incremental-csv-parser — npm install incremental-csv-parser · libregistry