{"id":13029,"library":"csv-spectrum","title":"CSV Spectrum Test Data","description":"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.","status":"maintenance","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/maxogden/csv-spectrum","tags":["javascript"],"install":[{"cmd":"npm install csv-spectrum","lang":"bash","label":"npm"},{"cmd":"yarn add csv-spectrum","lang":"bash","label":"yarn"},{"cmd":"pnpm add csv-spectrum","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only and expects `require()` for module loading. Direct ESM imports will fail without a CJS wrapper or specific tooling.","wrong":"import spectrum from 'csv-spectrum'","symbol":"spectrum","correct":"const spectrum = require('csv-spectrum')"}],"quickstart":{"code":"const spectrum = require('csv-spectrum');\n\nspectrum(function(err, data) {\n  if (err) {\n    console.error('Failed to load CSV spectrum data:', err);\n    return;\n  }\n\n  console.log(`Loaded ${data.length} CSV test cases.`);\n  // Example: Accessing the first test case\n  const firstCase = data[0];\n  console.log(`Test case name: ${firstCase.name}`);\n  console.log(`CSV buffer length: ${firstCase.csv.length}`);\n  console.log(`JSON buffer length: ${firstCase.json.length}`);\n  \n  // In a real test, you'd typically parse firstCase.csv and compare it with JSON.parse(firstCase.json)\n  // For instance, if you had a 'parseCsv' function:\n  // const parsedCsvResult = parseCsv(firstCase.csv.toString());\n  // const expectedJson = JSON.parse(firstCase.json.toString());\n  // assert.deepStrictEqual(parsedCsvResult, expectedJson, `Test failed for ${firstCase.name}`);\n});","lang":"javascript","description":"Demonstrates programmatic loading and initial inspection of all CSV and corresponding JSON test cases."},"warnings":[{"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');`.","message":"This 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"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.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module ... from ... not supported."},{"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.","cause":"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.","error":"TypeError: spectrum is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":""}