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

fix for trimmed quoted separators #154

Merged
merged 1 commit into from
Jan 27, 2024

Conversation

dejan1024
Copy link
Contributor

This is a fix for the following issue:
Sample document:

first, second
"yes", ", but"

Note the space after the separator. When loading this file (with pTrim = true and pAutoQuote = true), the second column will be read as only "\"", the comma after it will be interpreted as another separator.

The cause is in rapidcsv.h:1587:

if (cell.empty() || (cell[0] == mSeparatorParams.mQuoteChar))
{
    quoted = !quoted;
}

which does not trigger when there is whitespace before the opening quote.

This PR allows for whitespace in front of the first quote when trimming is enabled.

@d99kris d99kris self-assigned this Jan 10, 2024
@d99kris
Copy link
Owner

d99kris commented Jan 10, 2024

Hi @dejan1024 - thanks for contributing!
I believe the use-case makes sense for rapidcsv to handle. I'll try find some time to review the patch properly soonish and get it merged.

@d99kris d99kris changed the base branch from master to integrate-trimquote-fix January 27, 2024 14:22
@d99kris d99kris merged commit 5336a4c into d99kris:integrate-trimquote-fix Jan 27, 2024
3 checks passed
@d99kris
Copy link
Owner

d99kris commented Jan 27, 2024

Thanks again for contributing @dejan1024, the fix has been integrated now. I just added a test case, bumped version and did some minor code formatting fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants