I find particularly difficult reading binary file with Python. Can you give me a hand? I need to read this file, which in Fortran 90 is easily read by
int*4
To read a binary file to a bytes object:
from pathlib import Path
data = Path('/path/to/file').read_bytes() # Python 3.5+
To create an int from bytes 0-3 of the data:
i = int.from_bytes(data[:4], byteorder='little', signed=False)
To unpack multiple ints from the data:
import struct
ints = struct.unpack('iiii', data[:16])