Registry / testing / csv-spectrum

csv-spectrum

JSON →
library2.0.0jsnpmunverified

The `csv-spectrum` package offers a comprehensive, standardized collection of diverse CSV files specifically designed for rigorously testing and validating CSV parsing libraries. Its primary goal is to provide an 'acid test' for parsers, capturing a wide array of CSV formatting edge cases, common variations, and even malformed inputs to ensure robust implementation. Each CSV test case is conveniently paired with a corresponding JSON file, enabling straightforward verification of parsing results. Currently stable at version 2.0.0 (last updated approximately 8 years ago), this library is primarily used as a development dependency within the test suites of CSV processing tools. Its core value lies in offering programmatic access to a 'spectrum' of challenging CSV data, aiding developers in building highly resilient parsers. Due to its nature as a static dataset, it is in a maintenance status and does not see frequent updates or new features, focusing instead on stability and its intended purpose.

npm install csv-spectrum
INSTALL
IMPORT
SIG · CSV-SPECTRUM
C
csv-spectrum
testingjavascriptv2.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.

spectrum
const spectrum = require('csv-spectrum')
import spectrum from 'csv-spectrum'
This package is CommonJS-only and expects `require()` for module loading. Direct ESM imports will fail without a CJS wrapper or specific tooling.

Demonstrates programmatic loading and initial inspection of all CSV and corresponding JSON test cases.

const spectrum = require('csv-spectrum'); spectrum(function(err, data) { if (err) { console.error('Failed to load CSV spectrum data:', err); return; } console.log(`Loaded ${data.length} CSV test cases.`); // Example: Accessing the first test case const firstCase = data[0]; console.log(`Test case name: ${firstCase.name}`); console.log(`CSV buffer length: ${firstCase.csv.length}`); console.log(`JSON buffer length: ${firstCase.json.length}`); // In a real test, you'd typically parse firstCase.csv and compare it with JSON.parse(firstCase.json) // For instance, if you had a 'parseCsv' function: // const parsedCsvResult = parseCsv(firstCase.csv.toString()); // const expectedJson = JSON.parse(firstCase.json.toString()); // assert.deepStrictEqual(parsedCsvResult, expectedJson, `Test failed for ${firstCase.name}`); });
Debug
Known issues
gotchaThis package is exclusively CommonJS (CJS) and does not provide native ES Module (ESM) exports. Attempting to `import` it directly in an ESM context will result in errors.
fix
For ESM projects, use `const spectrum = require('csv-spectrum')` within a CJS wrapper or leverage Node.js's `createRequire` utility: `import { createRequire } from 'module'; const require = createRequire(import.meta.url); const spectrum = require('csv-spectrum');`.
affects: >=1.0.0
gotchaThe package has not been updated in approximately 8 years. While its comprehensive dataset remains valuable for CSV parsing tests, no new features, bug fixes, or security patches are expected.
fix
Be aware of its unmaintained status. For critical applications, consider auditing the test data yourself. For static test data, this is often acceptable, but it means no future adaptations to new JavaScript features or environments.
affects: >=2.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module ... from ... not supported.
Attempting to use `require()` in an ES Module context for a package that is not explicitly marked as CJS or trying to `import` a CJS-only package directly.
fix
In an ESM file, if you must use `require()`, utilize `import { createRequire } from 'module'; const require = createRequire(import.meta.url); const spectrum = require('csv-spectrum');`. Alternatively, use a build tool like Webpack or Rollup configured to handle CJS modules.
TypeError: spectrum is not a function
Incorrectly destructuring the package's module exports (e.g., `const { spectrum } = require('csv-spectrum')`) or attempting to use a named import where only a default export (or CJS `module.exports`) exists.
fix
Ensure you are using `const spectrum = require('csv-spectrum')` for CJS, as the package exports a single function directly as `module.exports`, not an object with a 'spectrum' property.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
csv-spectrum — npm install csv-spectrum · libregistry