Closed jnhansen closed 8 years ago
Hi,
Unfortunately, I do not think that getting CSVReader to do that is easy.
read_row needs to have the types of its operants at compile time to decide what to convert the data to. This a very fundamental property of the interface design and I do not even know how a dynamic variant would look like.
Oh, I see. Didn't think about different types per column.
In my particular case I would want all columns to be floating point and to be ignored if parsing into floating point fails. Or, alternatively, just take the char*
output and do the parsing myself.
I suppose I can get the LineReader to do the job for me.
I agree, this appears to be a great tool besides this limitation. I am not sure in what universe the average user knows the number of columns they want to read from a csv in advance of compiling the code.
Hi, firstly thanks for writing this CSV library!
I was wondering if it is possible to read a CSV file whose structure is only known at run-time. In particular, I have a vector of column headers (
std::vector<std::string>
) to read from the CSV which I would ideally like to pass to the parser directly – instead of a series of separate parameters which must be known at compile-time. The size of the vector is also only known at run-time.I am sure I could use the LineReader class for this, however, if the changes required in the CSVReader class are only minor I might try and adapt it.
Do you think the class is apt for this purpose?