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: initialize _format in CSVReader constructor #137

Merged
merged 1 commit into from
Dec 20, 2020
Merged

fix: initialize _format in CSVReader constructor #137

merged 1 commit into from
Dec 20, 2020

Conversation

bigerl
Copy link
Contributor

@bigerl bigerl commented Nov 13, 2020

I had trouble with the following code snippet:

csv::CSVFormat format;
format.delimiter(',').quote(false).no_header();
csv::CSVReader csv_reader(csv_file, format);
for (csv::CSVRow& row: csv_reader) { 
   // do sth with the rows 
}

Bug: First line is still parsed as headers not as a row like reported in #132 .

Cause: field _format was not initialized. That caused the function call in the following line to rely on the default constructed value of field CSVFormat _format:

this->initial_read();

Fix: Initialize the field _format in the constructor CSVReader::CSVReader(csv::string_view filename, CSVFormat format).
In the other constructors it is actually initialized. So it was probably simply looked over.

@vincentlaucsb vincentlaucsb merged commit b53fff9 into vincentlaucsb:master Dec 20, 2020
@vincentlaucsb
Copy link
Owner

Thanks for catching this.

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