[mlpack] Issue using FastCSV

Gopi Manohar Tatiraju deathcoderx at gmail.com
Fri Apr 2 06:05:23 EDT 2021


Hello,

I am exploring some csv parsers. Link
<https://github.com/ben-strasser/fast-cpp-csv-parser>
I went through the basic example:

# include "csv.h"
> int main(){
>   io::CSVReader<3> in("ram.csv");
>   in.read_header(io::ignore_extra_column, "vendor", "size", "speed");
>   std::string vendor; int size; double speed;
>   while(in.read_row(vendor, size, speed)){
>     // do stuff with the data
>   }
> }


Here you can see that the variables we pass into the function read_row get
assigned the values of the corresponding columns, but what if I have 20 or
25 columns, declaring so many variables won't make sense. There should be
some C++ syntax to handle cases like this. What is the concept called?

What if I don't know how many columns are there in my CSV file or what if
there are 100 columns, we should use a vector or an array. Agreed. But...I
don't want to pass 3 variables in the while loop(vendor, size, speed) but
what I want is, pass a single vector or an array and I can unpack the
vector to get those values.

Any help would be appreciated.

Thanks
Gopi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://knife.lugatgt.org/pipermail/mlpack/attachments/20210402/382e92cc/attachment.htm>


More information about the mlpack mailing list