Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] comment doesn't work when first field in line is escaped #777

Open
1 of 2 tasks
amitbeck opened this issue Feb 28, 2022 · 0 comments
Open
1 of 2 tasks

[BUG] comment doesn't work when first field in line is escaped #777

amitbeck opened this issue Feb 28, 2022 · 0 comments
Assignees
Labels

Comments

@amitbeck
Copy link

amitbeck commented Feb 28, 2022

Describe the bug
Seems that if a line, which is supposed to be a comment, starts with an escaped field (i.e. "# e.g. apples, oranges, grapes") - the line is not detected as a comment and is included in the output.
See reproduction on RunKit: https://runkit.com/embed/jhkygl35xji6

Parsing or Formatting?

  • Formatting
  • Parsing

To Reproduce
Steps to reproduce the behavior:

  1. Example file contents if applicable
    header 1,header 2,header 3
    "# comment 1, which includes a comma",# comment 2,# comment 3
    value 1,value 2,value 3
    
    referred to in the next example as escapedCommentFieldCsvString
  2. Example code to reproduce the issue
    Options passed to the parse method:
    {
        headers: true,
        comment: '#',
        trim: true,
        strictColumnHandling: true,
        ignoreEmpty: true
    }
  3. Output:
    { "header 1": "# comment 1, which includes a comma", "header 2": "comment 2", "header 3": "comment 3" }
    { "header 1": "value 1", "header 2": "value 2", "header 3": "value 3" }

Expected behavior
Output should not include comment lines whose first field includes comment token but is escaped.
The expected output is:

{ "header 1": "value 1", "header 2": "value 2", "header 3": "value 3" }

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: MacOS
  • OS Version: Big Sur 11.6.4
  • Node Version: v16.13.1

Additional context
@fast-csv/parse version 4.3.6

@amitbeck amitbeck added the bug label Feb 28, 2022
@amitbeck amitbeck changed the title [BUG] Comment not detected when in line which starts escaped field [BUG] comment doesn't work when first field in line is escaped Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants