ben-strasser / fast-cpp-csv-parser

fast-cpp-csv-parser
BSD 3-Clause "New" or "Revised" License
2.09k stars 435 forks source link

Usage of set_file_line is not clear #137

Closed mgaimann closed 1 year ago

mgaimann commented 1 year ago

Use case: I need to read the same CSV file multiple times. Problem: After I went through the CSV file the first time, I would like to go back to the beginning (line 0). When I use set_file_line(0), the internal state of LineReader (given by the variable data_begin I think) does not change. Hence, read_row() (and with that next_line()) finds the condition data_begin == data_end, meaning that a nullpointer is returned and not the correct data for the set line. Am I using set_file_line incorrectly or is it an implementation issue? Thank you for your help :)

ben-strasser commented 1 year ago

The functions only affect the error message. The naming is bad but changing this could break people. I added a comment to the readme.

They were written for edge cases where there is some boilerplate before the actual header (like # style comments or so) and you do not want to count them. If you actually want to switch files, create a new reader.