Closed TrungDinhT closed 3 years ago
This reader doesn't support multiple delimiters. You can specify multiple potential delimiters, but only one will be chosen and used.
Yes, I meant to specify multiple potential delimiters so that I can parse different csv files with different delimiters. However, as I explained, in case that I specify multiple potential delimiters in for CSVFormat
, no_header()
no longer has effect.
First of all, thank you for your great library.
For my use case, when I specify multiple possible delimiters for
CSVFormat
andno_header()
at the same time,no_header()
is ignored and the first row is always parsed as header row. This does not happen when I only specify one delimiter for the format.Looking into the implementation of
CSVReader
constructor in csv_reader.cpphttps://github.com/vincentlaucsb/csv-parser/blob/e4dd256b3a0dc76235084fce54e463bb7a98848f/include/internal/csv_reader.cpp#L159-L164
we can see that whenever
guess_delim()
istrue
, header row will be overwritten with the guess result format. Andguess_delim()
returnstrue
whenever there are multiple possible delimitershttps://github.com/vincentlaucsb/csv-parser/blob/e4dd256b3a0dc76235084fce54e463bb7a98848f/include/internal/csv_format.hpp#L135-L137
Quick fix would be something like this
format.header = (format.header == -1) ? guess_result.header_row - 1 : guess_result.header_row;
However, I don't know if that would introduce anything unintentional for the parser.
So, is this behavior intended with no-header-row case?