When using iterator (either old style begin()/end() or through a range-for loop) the value returned by n_rows() is off by 1. This does not happen when using the read_row pattern in a loop.
From what I can tell, the issue seems to come from CSVReader::begin() which gets a data row and construct the first iterator without incrementing the counter. Later ++ calls on the iterator correctly do that through a read_row call.
A possible fix may be to just replace the current approach of begin with a call to read_row instead of explicitly retrieving the data.
When using iterator (either old style begin()/end() or through a range-for loop) the value returned by
n_rows()
is off by 1. This does not happen when using theread_row
pattern in a loop.From what I can tell, the issue seems to come from
CSVReader::begin()
which gets a data row and construct the first iterator without incrementing the counter. Later ++ calls on the iterator correctly do that through aread_row
call.A possible fix may be to just replace the current approach of
begin
with a call toread_row
instead of explicitly retrieving the data.