Skip to content
This repository was archived by the owner on Jun 28, 2021. It is now read-only.
This repository was archived by the owner on Jun 28, 2021. It is now read-only.

skip_empty_lines property is not working as expected #308

Description

@hemanthreddyk

skip_empty_lines : Don't generate records for empty lines (line matching /\s*/), defaults to false.

As per the above definition it should ignore a row if it contains any string matching the regex '/\s*/'.
But when a row contains a space or tab in it, its not skipping the row and I am encountering following error
CsvError: Invalid Record Length: expect 2, got 1 on line 2

As a work around I have set trim as true and then it works.
Am I doing something wrong here or is it an issue?

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

parse(`
"key_1","key_2"\n\t\n"value 1","value 2"
`.trim(), {
  // trim: true,
  columns: false,
  skip_empty_lines: true
}, (err, records) => {
  if (err) {
    console.log('******', err)
  }
  assert.deepStrictEqual(
    records, [
         [
         'key_1',
         'key_2'
        ],
        [
         'value 1',
          'value 2'
        ]]
  )
})

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions