Iterate through text file extreamly fast
Hi,
I have some large files. Each having a classis table format. i need to extract information from first column second column and 4th column. Furthermore i need onyl one number from the second column. The way I am doing it right now is:
Code:
fstream fs;
fs.open (file.c_str(), ios::in);
int number = 0;
long unsigned pg = 0;
string query, subject, tmp;
while( !fs.eof()) {
fs >> query;
fs >> subject;
fs >> tmp;
fs >> number;
if (cnt = sscanf(subject, "pg|%lu", &pg))!=1)continue;
}
1. Is there a better (faster) way to do this?
2. if tmp is int then the code above might be a problematic, is there a way to just skip the third column?
b