CSVParse for Node.js


Option comment

Treat all the characters after this one as a comment. It can be made of one or multiple escape characters. It is disabled by default by defining an empty string "".

  • Type: boolean
  • Optional
  • Default: ""
  • Since: early days

The escape sequence can be defined at the begining of record (a line if the record delimiter is a line return) or anywhere else. Every characters found after the escape sequence will be disregarded.

Escaping is disabled inside a quoted field. The escape sequence will be preserved like any other bytes. It cannot be escaped.


The comment example insert two comments, one at the begining of the file and another one after a record.

const parse = require('csv-parse/lib/sync')
const assert = require('assert')

const data = `
# At the begening of a record
"world"# At the end of a record
const records = parse(data, {
  comment: "#"
assert.deepEqual(records, [
  [ "hello" ],
  [ "world" ]