csv-parser
csv-parser copied to clipboard
Incorrect n_rows() value when using iterators to loop over 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 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.
This may be the cause of #151 depending on the loop method used there.