CSVParse for Node.js

IssuesGitHub

Option raw

The raw option generates two properties raw and record instead of just the record. The raw property is the original CSV content and the record property is the parsed array or object literral.

All options are compatible but the generated records are structured differently.

Its behavior is similar to the one of the info option. Both options can be used conjointly.

Output

When the raw option is activated with the value true, the resulting record are made up of raw and record properties:

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

parse(`
a,b,c
d,e,f
`.trim(), {raw: true}, (err, records) => {
  assert.deepStrictEqual(records, [
    { record: [ 'a', 'b', 'c' ], raw: 'a,b,c\n' },
    { record: [ 'd', 'e', 'f' ], raw: 'd,e,f' }
  ]);
});

About

The Node.js CSV project is an open source product hosted on GitHub and developed by Adaltas.