vincentlaucsb / csv-parser

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

The empty function is totally wrong in the csv-parser #197

Closed freshduer closed 2 years ago

freshduer commented 2 years ago

image the empty() uses the n_rows() ,but n_rows() returns the number of rows that have been read so far,which is totally not right for the empty func. i suppose this should be modified , turn the n_rows() into some else

vincentlaucsb commented 2 years ago

empty() = "Whether or not the file or stream contains valid CSV rows".

If there is a valid CSV row, n_rows => 1 (see pic). Because empty() returns n_rows, empty() >= 1 if there is a valid CSV row.

Therefore empty() does what it's supposed to. QED.

image

freshduer commented 2 years ago

maybe u can try to use csv reader to load a csvfile and then use empty() function to see whether the return value is 0 or not it appears to me that the result is always 0 ----n_rows() returns the number of rows that have been read so far,but if you do not use the read_row() function,the _n_rows is always 0

freshduer commented 2 years ago

empty() = "Whether or not the file or stream contains valid CSV rows".

If there is a valid CSV row, n_rows => 1 (see pic). Because empty() returns n_rows, empty() >= 1 if there is a valid CSV row.

Therefore empty() does what it's supposed to. QED.

image

maybe u can try to use csv reader to load a csvfile and then use empty() function to see whether the return value is 0 or not it appears to me that the result is always 0 ----n_rows() returns the number of rows that have been read so far,but if you do not use the read_row() function,the _n_rows is always 0

freshduer commented 2 years ago

@vincentlaucsb maybe u can try to use csv reader to load a csvfile and then use empty() function to see whether the return value is 0 or not it appears to me that the result is always 0 ----n_rows() returns the number of rows that have been read so far,but if you do not use the read_row() function,the _n_rows is always 0