ben-strasser/fast-cpp-csv-parser

can we not ignore comment

mom1705 opened this issue · 7 comments

I am having really hard time writing code using csvparse because of lack of examples.
I want "#" in the starting of the line NOT to be considered as comment and I wrote

io::CSVReader<3, io::no_comment> in(strFileName.c_str());

and tried
io::CSVReader<3, io::no_comment<'#'>> in(strFileName.c_str());

and it gives compilation error

/fgw_dev/dev/libs/saxparser/include/csv.h:875:77: error: 'trim' is not a member of 'io::no_comment'
trim_policy::trim(col_begin, col_end);

io::CSVReader<3> in(strFileName.c_str()); works but if csv file has any line starting "#", it is not considered invalid/error which is my requirement.

I did read README and after that I tried

io::CSVReader<3, io::trim_chars<' '>,io::no_comment<'#'>> in(strFileName.c_str());

but it gave error
/fgw_dev/dev/libs/saxparser/include/csv.h:876:82: error: 'unescape' is not a member of 'io::no_comment'
quote_policy::unescape(col_begin, col_end);
^

my requirement is simple, I don't want to support "#" ( used for comment) and want it to throw error which I want to catch. Can u pls help

Thanks Ben, Can you pls. explain what will
CSVReader<3, trim_chars<' ', '\t'>, no_quote_escape<','>,
throw_on_overflow, single_line_comment<'#'>>

do ?
will it throw "on_overflow" error ?
atleast it compiled. Now let me see what does it do?

sure, thanks a lot.