d3-dsv is a robust JavaScript module from the D3.js ecosystem designed for parsing and formatting delimiter-separated values, primarily CSV (Comma-Separated Values) and TSV (Tab-Separated Values). The current stable version is 3.0.1, part of the d3 monorepo, which generally sees stable, infrequent major releases focusing on ecosystem alignment and modern JavaScript features. It adheres to RFC 4180 for CSV parsing, ensuring reliable data handling. Key features include direct parsing functions like `csvParse` and `tsvParse`, as well as a flexible `dsvFormat` method for handling arbitrary delimiters. A notable differentiator is its `autoType` function, introduced in v1.1.0, which automatically infers and converts string values to appropriate data types (e.g., numbers, dates) during parsing, significantly simplifying data preparation. The module is lightweight and offers both row-level and full-document parsing and formatting capabilities, making it suitable for both client-side browser applications (via ESM or UMD bundles) and server-side Node.js environments. Since version 3.0.0, it has adopted ES modules, requiring Node.js 12 or higher.
npm install d3-dsvVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing CSV, TSV, and custom delimiter-separated values (PSV) both with and without `autoType` for automatic type inference. Also shows how to format data back into CSV and custom DSV strings using various functions.
Migrate your project to use ES module `import` syntax. If using Node.js, ensure your `package.json` specifies `"type": "module"` or use `.mjs` file extensions. Update Node.js to version 12 or higher.
For projects requiring support for pre-ES2015 environments (like IE), stick to d3-dsv v1.x or use a transpilation step (e.g., Babel) to downlevel the JavaScript.
If encountering CSP errors related to `eval`, consider adjusting your CSP to include `script-src 'unsafe-eval'`. Alternatively, manually parse and type-convert data if `autoType` is not critical or if you prefer a stricter CSP without `unsafe-eval`.
Update to d3-dsv v1.1.2 or later to ensure consistent parsing behavior where missing trailing columns are represented as empty strings. If using older versions, explicitly handle `undefined` values during data processing.
Change your import statement to `import { csvParse } from 'd3-dsv';`. Ensure your environment (Node.js or bundler) is configured for ES modules.If in a modern browser using ES modules, use `import { csvParse } from 'd3-dsv';`. If in a legacy browser, ensure you load the UMD bundle (e.g., from a CDN) via a `<script>` tag *before* attempting to use `d3.csvParse`.Either upgrade your browser environment, use a transpilation tool (like Babel) to convert ES2015+ syntax to ES5 for wider compatibility, or downgrade to d3-dsv v1.x if older browser support is critical and transpilation is not an option.
No dependency data recorded yet.