Seeking
Seeking is the process of moving a pointer within a file to an arbitrary position. This allows you to get data from anywhere within the file without having to start at the beginning every time.
The seek() method can take several arguments. The first argument (offset) is the starting position of the pointer. The second, optional, argument is the seek direction from where the offset starts. The default value is 0 which indicates an offset relative to the beginning of the file, 1 is relative to the current position within the file, and 2 is relative to the end of the file.
The tell() method returns the current position of the pointer within the file. This can be useful for troubleshooting (to make sure the pointer is actually in the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access