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 file with missing column not parseable #75

Open
supipd opened this issue Dec 4, 2018 · 1 comment
Open

CSV file with missing column not parseable #75

supipd opened this issue Dec 4, 2018 · 1 comment

Comments

@supipd
Copy link

supipd commented Dec 4, 2018

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

@TedPoch
Copy link

TedPoch commented Apr 2, 2020

Hate to bring up old issues, but I'm having a very similar issue. I suspect I'm doing something wrong, or missing something essential from the documentation. Was there a solution discussed offline for the above issue?

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

No branches or pull requests

2 participants