-
Notifications
You must be signed in to change notification settings - Fork 440
Open
Description
Perhaps my misconception, but fast-cpp-csv-parser is not able to parse CSV file with missing separators at rows end. Maybe CSV not exact according standarts, but in practice is often used
test.csv
a;b;c
1;2;3
1;2;
1;2
1;;
1;
1
main.c
int main(int argc, char** argv)
{
io::CSVReader<3, io::trim_chars<' ', '\t'>, io::no_quote_escape<';'>> in("test.csv");
in.read_header(io::ignore_extra_column, "a", "b", "c");
std::string vendor, size, speed;
try {
while(in.read_row(vendor, size, speed)){
// do stuff with the data
}
cout << "ignore_extra_column OK" << endl;
} catch(exception &e) {
cout << "ignore_extra_column BAD" << endl;
}
io::CSVReader<3, io::trim_chars<' ', '\t'>, io::no_quote_escape<';'>> in1("test.csv");
in1.read_header(io::ignore_missing_column, "a", "b", "c");
try {
while(in.read_row(vendor, size, speed)){
// do stuff with the data
}
cout << "ignore_missing_column OK" << endl;
} catch(exception &e) {
cout << "ignore_missing_column BAD" << endl;
}
io::CSVReader<3, io::trim_chars<' ', '\t'>, io::no_quote_escape<';'>> in2("test.csv");
in2.read_header(io::ignore_no_column, "a", "b", "c");
try {
while(in.read_row(vendor, size, speed)){
// do stuff with the data
}
cout << "ignore_no_column OK" << endl;
} catch(exception &e) {
cout << "ignore_no_column BAD" << endl;
}
}
output:
ignore_extra_column BAD
ignore_missing_column BAD
ignore_no_column BAD
Metadata
Metadata
Assignees
Labels
No labels