Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
The d3-dsv npm package is designed for parsing and formatting delimiter-separated values, such as CSV and TSV files. It provides a simple and efficient way to work with structured data in text format, making it easier to import, analyze, and export data in web applications.
Parsing CSV strings
This feature allows you to parse a CSV string into an array of objects, where each object represents a row of the CSV, with properties corresponding to column names.
"var d3 = require('d3-dsv');\nvar csvString = 'name,age\nAlice,30\nBob,42';\nvar data = d3.csvParse(csvString);\nconsole.log(data);"
Formatting objects to CSV
This feature enables you to convert an array of objects into a CSV string, where each object in the array represents a row in the CSV and the object properties represent columns.
"var d3 = require('d3-dsv');\nvar data = [{ name: 'Alice', age: 30 }, { name: 'Bob', age: 42 }];\nvar csvString = d3.csvFormat(data);\nconsole.log(csvString);"
Parsing TSV strings
Similar to parsing CSV strings, this feature allows for parsing TSV (Tab-Separated Values) strings into an array of objects, facilitating the handling of TSV formatted data.
"var d3 = require('d3-dsv');\nvar tsvString = 'name\tage\nAlice\t30\nBob\t42';\nvar data = d3.tsvParse(tsvString);\nconsole.log(data);"
Formatting objects to TSV
This feature allows for converting an array of objects into a TSV string, making it easy to generate TSV formatted data from JavaScript objects.
"var d3 = require('d3-dsv');\nvar data = [{ name: 'Alice', age: 30 }, { name: 'Bob', age: 42 }];\nvar tsvString = d3.tsvFormat(data);\nconsole.log(tsvString);"
Papa Parse is a powerful CSV (Comma Separated Values) parser that can convert CSV files into JSON and back. It is similar to d3-dsv in its ability to handle CSV data but offers a more extensive set of features for handling large files and streaming.
csv-parser is a Node.js module that transforms CSV into JSON at the rate of 90,000 rows per second. It provides a simple and efficient streaming API, making it a good choice for processing large CSV files. It is similar to d3-dsv but focuses more on high-performance streaming.
fast-csv is another npm package for parsing and formatting CSV files. It offers both synchronous and asynchronous APIs and includes features for transforming data. While it shares functionality with d3-dsv, fast-csv emphasizes speed and flexibility in handling CSV data.
A parser and formatter for delimiter-separated values, most commonly comma-separated values (CSV) or tab-separated values (TSV).
To parse CSV in the browser:
<script src="dsv.js"></script>
<script>
console.log(dsv.csv.parse("foo,bar\n1,2")); // [{foo: "1", bar: "2"}]
</script>
To parse CSV in Node.js, npm install d3-dsv
, and then:
var dsv = require("d3-dsv");
console.log(dsv.csv.parse("foo,bar\n1,2")); // [{foo: "1", bar: "2"}]
To define a new delimiter, use the dsv constructor:
var psv = dsv.dsv("|");
console.log(psv.parse("foo|bar\n1|2")); // [{foo: "1", bar: "2"}]
For more usage, see D3’s wiki page.
FAQs
A parser and formatter for delimiter-separated values, such as CSV and TSV
The npm package d3-dsv receives a total of 3,101,211 weekly downloads. As such, d3-dsv popularity was classified as popular.
We found that d3-dsv demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.