CSVParse for Node.js

IssuesGitHub

Option skip_records_with_empty_values

The skip_records_with_empty_values option don't generate records for lines containing empty values (column matching /\s*/), empty Buffer or equals to null and undefined if their value was casted, defaults to false.

Usage

In this example, the second line contains empty fields composed of zero characters, spaces and tabs:

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

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

About

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