Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 7, 2024 via pnpm

csv-parse 5.5.0

CSV parsing implementing the Node.js `stream.Transform` API
Package summary
Share
0
issues
1
license
1
MIT
Package created
25 Oct 2013
Version published
25 Aug 2023
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
csv-parse@5.5.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of csv-parse 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does csv-parse do?

The csv-parse package is a robust tool for parsing CSV text input into arrays or objects. Built for Node.js and the web, it implements the Node.js stream.Transform API, providing a combination of simplicity and power. Whether you're handling large datasets or small, csv-parse can be a versatile addition to your JavaScript toolset.

How do you use csv-parse?

To use csv-parse, you'd start by installing the package with npm. If you're interested in the full CSV module, you can run npm install csv. For just the CSV parser, use npm install csv-parse. Once installed, csv-parse can be used with either a simpler callback-based API or a scalable stream-based API.

Here's an example of how to parse CSV data using the stream API:

import assert from 'assert';
import { parse } from 'csv-parse';

const records = [];
// Initialize the parser
const parser = parse({
  delimiter: ':'
});
// Use the readable stream api to consume records
parser.on('readable', function(){
  let record;
  while ((record = parser.read()) !== null) {
    records.push(record);
  }
});
// Catch any error
parser.on('error', function(err){
  console.error(err.message);
});
// Test that the parsed records matched the expected records
parser.on('end', function(){
  assert.deepStrictEqual(
    records,
    [
      [ 'root','x','0','0','root','/root','/bin/bash' ],
      [ 'someone','x','1022','1022','','/home/someone','/bin/bash' ]
    ]
  );
});
// Write data to the stream
parser.write("root:x:0:0:root:/root:/bin/bash\n");
parser.write("someone:x:1022:1022::/home/someone:/bin/bash\n");
// Close the readable stream
parser.end();

In this case, the parser is reading data with ':' as a delimiter.

Where are the csv-parse docs?

You can find comprehensive documentation for csv-parse on its project homepage (https://csv.js.org/parse/). Here links are provided for specific sections, including the API (https://csv.js.org/parse/api/), a guide to options (https://csv.js.org/parse/options/), info properties (https://csv.js.org/parse/info/), common errors (https://csv.js.org/parse/errors/), and a collection of examples (https://csv.js.org/project/examples/) to help you get started.