I am parsing a simple text file with two columns in C.
The two columns are separated by a tab. While I need the whole line in a later stage I also have to extract the value in the second column.
My implementation of this part is so far (reading a gzipped file):
while (! gzeof(fp)) {
// here I keep the whole line since I need it later (can I do this also faster?)
strcpy(line_save, line);
// get the value in the second column (first removing the newline char.):
line[strcspn(line, "\n")] = 0;
linkage = strtok(line,"\t");
linkage = strtok(NULL,"\t"); // here I have the value in the second col. as the result
// do stuff
gzgets(fp, line, LL);
}
What is a more time-efficient way to do this?
I am reading a gzipped file. gzeof()
checks if EOF is reached and gzgets()
reads one line.
I am not looking for an overly advanced solution here, but I am interested mainly in the "low-hanging fruits". However, if you can present more advances solutions I do not mind.