Hello there,
submissiontime length finishtime remainingtime
1031 17:11 574.1025391 MB 1050 17:30 1
1326 22:06 536.0175781 MB 1343 22:23 2
2721 45:21:00 608.1279297 MB 2741 45:41:00 3
32 0:32 575.8115234 MB 51 0:51 4
1161 19:21 652.6259766 MB 1182 19:42 5
937 15:37 288.7597656 MB 946 15:46 6
3087 51:27:00 912.9931641 MB 3117 51:57:00 7
I'm trying to read this Excel (CSV) file and display the elements, I'm only interested in displaying the elements with title above, (1st, 3rd, 5th and 7th coloumns), I managed to do this but, the final line is duplicated and starts by 0 when I use the code below, how can I get red of the last line ?:
the output:
1031 574.1025391 1050 1
1326 536.0175781 1343 2
2721 608.1279297 2741 3
32 575.8115234 51 4
1161 652.6259766 1182 5
937 288.7597656 946 6
3087 912.9931641 3117 7
0 912.9931641 3117 7
The code:
list<FileInfo*>futurelist;
void FileInput()
{
ifstream file ("test1.csv");
string value1;
string value2;
string value3;
string value4;
string value5;
string value6;
string value7;
while ( file.good() )
{
getline ( file,value1, ',' );
getline(file,value2, ',');
getline(file,value3, ',');
getline(file,value4, ',');
getline(file,value5, ',');
getline(file,value6, ',');
getline(file,value7);
FileInfo* fi = new FileInfo();
fi->submissiontime = atoi(value1.c_str());
fi->length= atof(value3.c_str());
fi->finishtime= atoi(value5.c_str());
fi->remainingtime= atoi(value7.c_str());
futurelist.push_back(fi);
}
file.close();
}
int main()
{
FileInput();
cout << futurelist.size()<<endl;
cout << "Contents: ";
list<FileInfo*>::iterator p = futurelist.begin();
while(p != futurelist.end()) {
cout<<endl;
cout << (*p)->submissiontime << " ";
cout << (*p)->length << " ";
cout << (*p)->finishtime << " ";
cout << (*p)->remainingtime << " ";
cout<<endl;
p++;
}
cout << "\n\n";
return 0;
}