Do you know the maximum number of rows and columns?
no i don't know the max size of rows and columns, I just can assume in won't be more than [30][20].
But can we read somehow element by element until we get nextline(\n)?
You don't need to count columns. In parse_data_row (from the previously linked post), row is a vector. Simply call row.size() to get the number of columns in a particular row.
bool parse_data_row(const string & line, vector<ROW> & vdata)
{ stringstream iss(line);
string cell;
double val;
ROW row;
while (!iss.eof())
{ // good status, get one cell
if (!getline(iss, cell, ';'))
returnfalse; // some error
stringstream convertor(cell);
convertor >> val; // Input double from cell
row.push_back (val); // Add value to row
}
vdata.push_back (row); // Add row to vector of rows
cout<<endl<<"size= "<<row.size()<<endl;
returntrue; // end of line
}
At line 8, if (!getline(iss, cell, ';'))
the delimiter is specified as a semicolon ';'
However, the sample data in the opening post has no semicolons.
You should change the delimiter to whatever is separating the items in your data file, probably a space. Or simplify the code and get rid of the getline, perhaps something like this:
7 8 9 10
while (iss >> val)
{
row.push_back (val); // Add value to row
}