In Python, I'm trying to extract some data from a binary file. I know the offsets of my data. They are always the same. For instance, written beneath is the first 4 offsets and the converted offset as a decimal value.
I know that each offset (after the first one), is 3121 decimals apart, so is there a way I can just skip to the next offset? How do I move 3121 decimals to the next offset?
There are 128 offsets that I need to extract. I hope there is a way of dynamically determining the difference (number of bytes) between offsets?
I can then get the same data each time, using 0x100 to extract 256 characters from the offset.
use file.seek()
to skip between locations in a file. In this case, to go to the next location in the file, you would use file.seek(3121, 1)
which seeks 3121 bytes ahead relative to the current position.
EDIT: I didn't realize you were changing the file position after opening it, so it should actually be 2685 bytes that you're seeking ahead each time, to account for the 256 you read.