ben-strasser / fast-cpp-csv-parser

fast-cpp-csv-parser
BSD 3-Clause "New" or "Revised" License
2.15k stars 440 forks source link

Dont throw too_many_columns() when using ignore_extra_column #27

Closed hmalphettes closed 8 years ago

hmalphettes commented 8 years ago

Hi! Many thanks for a beautiful library.

I noticed that when we use in.read_header(io::ignore_extra_column, "vendor", "size", "speed"); if the csv file's last column is not "vendor", "size" or "speed" a too_many_columns error is thrown.

Would it make sense to not throw that error if we used the ignore_extra_column policy on the reader?

ben-strasser commented 8 years ago

Hi,

On 07/26/2016 07:06 AM, Hugues Malphettes wrote:

Hi! Many thanks for a beautiful library.

Thanks :)

I noticed that when we use |in.read_header(io::ignore_extra_column, "vendor", "size", "speed");| if the csv file's last column is not "vendor", "size" or "speed" a |too_many_columns| error is thrown.

Would it make sense to not throw that error if we used the |ignore_extra_column| policy on the reader?

Thanks for the bug report, and yes, ignore_extra_column should ignore additional columns. However, I cannot reproduce the error. My code is

main.cpp:

include "csv.h"

include

using namespace std;

int main(){ io::CSVReader<3> in("ram.csv"); in.read_header(io::ignore_extra_column, "vendor", "size", "speed"); std::string vendor; int size; double speed; while(in.read_row(vendor, size, speed)){ cout << vendor << ":" << size << ":" << speed << endl; } }

ram.csv:

size,speed,vendor,aba 1,3.2,foo,b 5,4.7,bar,a

output:

foo:1:3.2 bar:5:4.7

I am using the latest version of library. Could you please give me a minimal example that triggers the bug?

Best Regards Ben Strasser

hmalphettes commented 8 years ago

My apologies, I can't reproduce the issue anymore. I tried on your example and then on mine. Sorry for the noise. Best regards, Hugues