Ok, you have a series of text characters that periodically have a "\n" in the data stream.
The disk and the file system hides some "ugliness" from you, but basically you can think of a disk file as a stream of bytes from 0 to N.
A "line" has some number of characters followed by "\n". There is no general way to "jump over 5 lines" because the number of characters contained within those lines is variable and unknown. You have to read sequentially through the bytes and count the number of "\n" chars to decide that you've skipped over say 5 lines.
There are some types of disk data structures that have fixed length records and in that case, it is possible to calculate "the starting byte address" of record 213 and you can "seek" (or in other words "jump") there.
The disk system reads sequential characters very quickly. Even a couple of thousand characters of "header" is normally of no consequence.
Now if you have say 1MB of stuff to "plow through" at the beginning, then maybe you have the wrong data structure?
But it appears to me that you just need to "read and throw away" the lines that don't matter until you get to the "real stuff".
In reply to Re: Reading lines from a specific location in a text file.
by Marshall
in thread Reading lines from a specific location in a text file.
by peokai
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |