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

try catch not working in CSVReader object if strict parsing is there #62

Closed
codewithrajranjan opened this issue Nov 19, 2019 · 2 comments

Comments

@codewithrajranjan
Copy link

The CSVFormat object is below

 CSVFormat csvFileFormat;
 csvFileFormat.column_names("name,age");
 csvFileFormat.strict_parsing();

The data in csv file is like

A,10
B,5000
C,30
D,100
E,100,5000

Note that the fifth row has three columns.

I am creating a csv reader object but it is not catching the std::runtime_error during the csv reader object creation

try {
        CSVReader reader(filePath,csvFileFormat);
}catch(std::runtime_error& e){
   std::cout << "Error" << std::endl;
}

My main motive is to get all the malformed records present inside the csv file so that I can write those malformed records in a separate file.

@vincentlaucsb
Copy link
Owner

Errors with data will be thrown while reading the data. but currently errors are only thrown for missing quotes (maybe I should document that better).

You can read http://vincela.com/csv/md_docs_source_variable_row_lengths.html to see how to get malformed records. I'm not sure if I like the current API for doing so, so let me know how you feel.

@vincentlaucsb
Copy link
Owner

Malformed row handling will be made easier by #66

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