adaltas / adaltas/node-csv

Issues with ignore_last_delimiters

Open
#330 9 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
4.3k
Forks
299
Avg merge
16h 19m
Merged PRs (30d)
1

Description

Describe the bug

ignore_last_delimiters: true seems to have some issues:

  1. If you don't use relax_quotes: true then it fails with CsvError$1: Invalid Closing Quote: got "," at line 4 instead of delimiter, record delimiter, trimable character (if activated) or comment
  2. If you use trim: true or rtrim: true then it fails with CsvError$1: Invalid Closing Quote: found non trimable byte after quote at line 4
  3. If you avoid the two issues above then the final string ends up with extra quotes and the final delimiter, e.g. "'123123-12312312", (the double quotes are part of the string)

To Reproduce

const fs = require('fs');
const csv = require('csv');

const INPUT = `
Date, Type, Description, Value, Balance, Account Name, Account Number

11/02/2022,BAC,"'FOO",10.00,33432.80,"'REF","'123123-12312312",
`;

const stream = csv.parse(INPUT, {
    skip_empty_lines: true,
    ltrim: true,
    rtrim: true,
    columns: true,
    relax_quotes: true,
    ignore_last_delimiters: true,
});

Additional context

  • node version: 16.14.0
  • csv version: 6.0.5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the csv.parse entry point and run the provided reproduction using the listed parser options. Trace the ignore_last_delimiters handling for quoted final fields, then verify that the three reported cases parse without errors and that the final value contains no extra quotes or delimiter.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.