CSVParse for Node.js

IssuesGitHub

Option from_line

The from_line option handles records starting from a requested line number. The counting of lines start at 1 which is the default value, thus the first line is 1.

  • Type: number
  • Coercion: string to number
  • Optional
  • Default: 1
  • Validation: positive integer
  • Since: 4.0.0
  • Related: to_line, from, to — see Available Options

Simple example with inferred column names

This example skip the first lines and return records after the second line. The first records is used to determine column names:

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

parse(`
x,x
a,b
1,2
`.trim(), {
  columns: true,
  from_line: 2
}, function(err, records){
  assert.deepStrictEqual(
    records, [{
      a: '1',
      b: '2'
    }]
  );
});

About

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