vincentlaucsb / csv-parser

A high-performance, fully-featured CSV parser and serializer for modern C++.
MIT License
901 stars 150 forks source link

unable to use CSVFormat.header_row #185

Closed omerbrandis closed 2 years ago

omerbrandis commented 2 years ago

hello,

I'm trying to use this lib on a csv that has its header on the second row ( ubuntu 16, csv parser version 2.1.3 )

csv::CSVReader  MyCsvReader(FileName)
for (auto & CurrentCsvRow: MyCsvReader)
{
     std::cout << "read row "<< std::endl;
}

writes the expected number of rows to sysout ( = the number of rows in the file)

but

csv::CSVFormat  Format;
    Format.header_row(1);
csv::CSVReader  MyCsvReader(FileName.Format)
for (auto & CurrentCsvRow: MyCsvReader)
{
     std::cout << "read row "<< std::endl;
}

only writes one row to stdout.

any ideas ? thanks, Omer.

omerbrandis commented 2 years ago

adding Format.variable_columns(csv::VariableColumnPolicy::KEEP); solved the problem for me. :-)