I have a some sets of binary files (some are potentially large (100MB)) that contain 4 byte integers.
Can anyone supply a code snippet to show how to extract each 4 byte
Check out the NumPy fromfile function. You provide a simple type annotation about the data to be read, and the function efficiently reads it into a NumPy ndarray
object.
import numpy as np
np.fromfile(file_name, dtype='
You can change dtype
to reflect size and byte order as well. See here for some examples.