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

CSV files ending with a commented line without a line-break will result in the commented line as part of the final data #156

Closed
yoons1 opened this issue Feb 8, 2024 · 2 comments
Assignees
Labels

Comments

@yoons1
Copy link

yoons1 commented Feb 8, 2024

Description:
CSV files ending with a commented line without a line-break will result in the commented line as part of the final data.

How to reproduce it:
Parse the example below.

x,y,z
1,2,3
4,5,6

# this is a last line comment without \n

Environment:

  • Version: 8.80
  • OS / distro: Linux

Fix should be:

Only perform mData.push_back(row)

      // Handle last line without linebreak
      if (!cell.empty() || !row.empty())
      {
        row.push_back(Unquote(Trim(cell)));
        cell.clear();
        mData.push_back(row);
        row.clear();
      }

only under the condition
!(mLineReaderParams.mSkipCommentLines && (row.at(0)[0] == mLineReaderParams.mCommentPrefix))

@d99kris
Copy link
Owner

d99kris commented Feb 10, 2024

Hi @yoons1 - thanks for reporting the issue and proposing a fix. 👍

I can reproduce the problem and I agree with the fundamentals of the proposed fix.

I'll try push a fix for this soon.

@d99kris
Copy link
Owner

d99kris commented Feb 10, 2024

Hi again - this issue should be fixed by above commit. Please let me know in case you're still encountering issues after the fix.

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

2 participants