Utility function that reads a model from a CSV file.
{
int csvRow = 0;
while (f) {
std::string line;
getline(f, line);
if (f) {
typedef boost::tokenizer<boost::escaped_list_separator<char> >
CsvTokenizer;
CsvTokenizer tok(line);
int col = 0;
for (CsvTokenizer::iterator i = tok.begin();
i != tok.end(); ++i, ++col) {
if (firstLineIsHeaders && csvRow == 0)
else {
int dataRow = firstLineIsHeaders ? csvRow - 1 : csvRow;
if (numRows != -1 && dataRow >= numRows)
return;
std::string s = *i;
boost::any data;
char *end;
int i = std::strtol(s.c_str(), &end, 10);
if (*end == 0)
data = boost::any(i);
else {
double d = std::strtod(s.c_str(), &end);
if (*end == 0)
data = boost::any(d);
else
}
model->
setData(dataRow, col, data);
}
}
}
++csvRow;
}
}