Skip to content

Parser.options.columns no longer contains array of column names from [email protected]+ #460

@richardlay

Description

@richardlay

Describe the bug

When we upgraded from [email protected] to version >=6.1.0, our csv parsing logic broke.
We use from_line in our logic depending on the file.
We noticed that in [email protected], Parser.options.columns used to be set to something that looks like:

[
  { name: 'invoiceReference' },
  { name: 'sequenceNumber' },
  { name: 'providerNumber' },
  ...
]

Which works for any value that is set for from_line.

However in 6.1.0+, when you set from_line >= 2, Parser.options.columns becomes:

true

To Reproduce

I believe this also needs a CSV file with a BOM char.

Example:

        const csvIterator = Fs.createReadStream(localFilePath).pipe(
            CsvParser({
                columns: true,
                trim: true,
                bom: true,
                from_line: 2
            })
        );

        for await (let record of csvIterator) {
                console.log(csvIterator.options?.columns); // will log out 'true'
        }

Additional context

It looks like we can use another field Parser.api.options.columns. This is set correctly for all scenarios.
But hopefully this might help someone who had the same issue.

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