I am attempting to read in a comma delimited file and only take in the first three values.
At the moment the code I have obviously does not work.
The text file is laid out like this:
1249968.646,16761001.880,1206.990,1,2,104,3,218210.549527
At the moment this is what my read in code looks like:
if(canopyfile)
{
string token;
stringstream iss;
while ( getline(canopyfile, line) )
{
iss << line;
while ( getline(iss, token, readinmode) )
{
x = token;
getline(iss, token, readinmode);
y = token;
getline(iss, token, readinmode);
z = token;
iss.clear();
}
holder.setx(atof(x.c_str()));
holder.sety(atof(y.c_str()));
holder.setz(atof(z.c_str()));
canopyvec.push_back(holder);
}
} else {
cout << "Can not Open the Canopy File!" << endl;
usage();
}
This wouldn't be much of a problem if I knew all my files would be formatted the same way, but some switch where the values are and even the number of values, except for the first three.
Any help would be appreciated, Thanks in advance.
Cameron