I am parsing a CSV file, which has a known structure of string,int,int,double
.
I am writing a function that parses a CSV file line-by-line. I am trying to design it so that it looks something like this:
void foo(const string& csvline){
std::stringstream csvStream(csvline);
std::string s; int i1; int i2; double d;
csvline >> s;
csvline >> i1;
csvline >> i2;
csvline >> d;
}
Is there a way to do this for CSV files?
I know that if they were separated by spaces, this will work out of the box. But what about for a CSV file (or an arbitrary delimiter, for that matter)?