CSVParse for Node.js


Option from

Table of Contents

The from option handles records starting from a requested number of records. Count is 1-based, for example, provides 1 (and not 0) to emit first record.

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

Inferred column names

When the column option is active, the first record is treated as a header. It is not accounted as a record. Thus, the first record is used to retrieve the properties names and the count start from the next record.

This example read the first a,b record to determine column names, skip the next record and return records afterward.

const parse = require('csv-parse')
const assert = require('assert')

`.trim(), {
  columns: true,
  record_delimiter: '|',
  from: 2
}, function(err, records){
    records, [{
      a: '3',
      b: '4'