csv-parse
CSV parsing implementing the Node.js `stream.Transform` API
Last updated 2 years ago by david .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install csv-parse 
SYNC missed versions from official npm registry.

CSV parser for Node.js and the web

Build Status NPM NPM

The csv-parse package is a parser converting CSV text input into arrays or objects. It is part of the CSV project.

It implements the Node.js stream.Transform API. It also provides a simple callback-based API for convenience. It is both extremely easy to use and powerful. It was first released in 2010 and is used against big data sets by a large community.

Documentation

Main features

  • Flexible with lot of options
  • Multiple distributions: Node.js, Web, ECMAScript modules and CommonJS
  • Follow the Node.js streaming API
  • Simplicity with the optional callback API
  • Support delimiters, quotes, escape characters and comments
  • Line breaks discovery
  • Support big datasets
  • Complete test coverage and lot of samples for inspiration
  • No external dependencies
  • Work nicely with the csv-generate, stream-transform and csv-stringify packages
  • MIT License

Usage

Run npm install csv to install the full csv module or run npm install csv-parse if you are only interested by the CSV parser.

Use the callback and sync APIs for simplicity or the stream based API for scalability.

Example

The API is available in multiple flavors. This example illustrates 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();

Contributors

The project is sponsored by Adaltas, an Big Data consulting firm based in Paris, France.

Current Tags

  • 5.3.6                                ...           latest (2 years ago)

129 Versions

  • 5.3.6                                ...           2 years ago
  • 5.3.5                                ...           2 years ago
  • 5.3.4                                ...           2 years ago
  • 5.3.3                                ...           2 years ago
  • 5.3.2                                ...           2 years ago
  • 5.3.1                                ...           2 years ago
  • 5.3.0                                ...           2 years ago
  • 5.2.2                                ...           2 years ago
  • 5.2.1                                ...           2 years ago
  • 5.2.0                                ...           2 years ago
  • 5.1.0                                ...           3 years ago
  • 5.0.4                                ...           3 years ago
  • 5.0.3                                ...           3 years ago
  • 5.0.2                                ...           3 years ago
  • 5.0.1                                ...           3 years ago
  • 5.0.0                                ...           3 years ago
  • 4.16.3                                ...           3 years ago
  • 4.16.2                                ...           3 years ago
  • 4.16.0                                ...           4 years ago
  • 4.15.4                                ...           4 years ago
  • 4.15.3                                ...           4 years ago
  • 4.15.2                                ...           4 years ago
  • 4.15.1                                ...           4 years ago
  • 4.15.0                                ...           4 years ago
  • 4.14.2                                ...           4 years ago
  • 4.14.1                                ...           4 years ago
  • 4.14.0                                ...           4 years ago
  • 4.13.1                                ...           4 years ago
  • 4.13.0                                ...           4 years ago
  • 4.12.0                                ...           4 years ago
  • 4.11.1                                ...           4 years ago
  • 4.10.1                                ...           5 years ago
  • 4.10.0                                ...           5 years ago
  • 4.9.1                                ...           5 years ago
  • 4.9.0                                ...           5 years ago
  • 4.8.9                                ...           5 years ago
  • 4.8.8                                ...           5 years ago
  • 4.8.7                                ...           5 years ago
  • 4.8.6                                ...           5 years ago
  • 4.8.5                                ...           5 years ago
  • 4.8.4                                ...           5 years ago
  • 4.8.3                                ...           5 years ago
  • 4.8.2                                ...           5 years ago
  • 4.8.1                                ...           5 years ago
  • 4.8.0                                ...           5 years ago
  • 4.7.0                                ...           5 years ago
  • 4.6.5                                ...           5 years ago
  • 4.6.4                                ...           5 years ago
  • 4.6.3                                ...           5 years ago
  • 4.6.2                                ...           5 years ago
  • 4.6.1                                ...           5 years ago
  • 4.6.0                                ...           5 years ago
  • 4.5.0                                ...           5 years ago
  • 4.4.7                                ...           5 years ago
  • 4.4.6                                ...           5 years ago
  • 4.4.5                                ...           5 years ago
  • 4.4.4                                ...           5 years ago
  • 4.4.3                                ...           6 years ago
  • 4.4.2                                ...           6 years ago
  • 4.4.1                                ...           6 years ago
  • 4.4.0                                ...           6 years ago
  • 4.3.4                                ...           6 years ago
  • 4.3.3                                ...           6 years ago
  • 4.3.2                                ...           6 years ago
  • 4.3.1                                ...           6 years ago
  • 4.3.0                                ...           6 years ago
  • 4.2.0                                ...           6 years ago
  • 4.1.0                                ...           6 years ago
  • 4.0.1                                ...           6 years ago
  • 4.0.0                                ...           6 years ago
  • 3.2.0                                ...           6 years ago
  • 3.1.3                                ...           6 years ago
  • 3.1.2                                ...           6 years ago
  • 3.1.1                                ...           6 years ago
  • 3.1.0                                ...           6 years ago
  • 3.0.0                                ...           6 years ago
  • 2.5.0                                ...           7 years ago
  • 2.4.1                                ...           7 years ago
  • 2.4.0                                ...           7 years ago
  • 2.3.0                                ...           7 years ago
  • 2.2.0                                ...           7 years ago
  • 2.1.0                                ...           7 years ago
  • 2.0.4                                ...           7 years ago
  • 2.0.3                                ...           7 years ago
  • 2.0.2                                ...           7 years ago
  • 2.0.0                                ...           7 years ago
  • 1.3.3                                ...           7 years ago
  • 1.3.2                                ...           7 years ago
  • 1.3.1                                ...           7 years ago
  • 1.3.0                                ...           7 years ago
  • 1.2.4                                ...           7 years ago
  • 1.2.3                                ...           7 years ago
  • 1.2.2                                ...           7 years ago
  • 1.2.1                                ...           7 years ago
  • 1.2.0                                ...           8 years ago
  • 1.1.12                                ...           8 years ago
  • 1.1.11                                ...           8 years ago
  • 1.1.10                                ...           8 years ago
  • 1.1.9                                ...           8 years ago
  • 1.1.8                                ...           8 years ago
  • 1.1.7                                ...           8 years ago
  • 1.1.6                                ...           8 years ago
  • 1.1.5                                ...           8 years ago
  • 1.1.4                                ...           8 years ago
  • 1.1.3                                ...           8 years ago
  • 1.1.2                                ...           8 years ago
  • 1.1.1                                ...           9 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.6                                ...           9 years ago
  • 1.0.5                                ...           9 years ago
  • 1.0.4                                ...           9 years ago
  • 1.0.3                                ...           9 years ago
  • 1.0.2                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
  • 0.1.4                                ...           9 years ago
  • 0.1.3                                ...           10 years ago
  • 0.1.2                                ...           10 years ago
  • 0.1.1                                ...           10 years ago
  • 0.1.0                                ...           10 years ago
  • 0.0.9                                ...           10 years ago
  • 0.0.8                                ...           10 years ago
  • 0.0.6                                ...           10 years ago
  • 0.0.5                                ...           10 years ago
  • 0.0.4                                ...           11 years ago
  • 0.0.3                                ...           11 years ago
  • 0.0.2                                ...           11 years ago
  • 0.0.1                                ...           11 years ago
  • 0.0.0                                ...           11 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (19)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |