[Numpy-discussion] R: fast numpy.fromfile skipping data chunks

Andrea Cimatoribus Andrea.Cimatoribus at nioz.nl
Wed Mar 13 10:18:53 EDT 2013

This solution does not work for me since I have an offset before the data that is not a multiple of the datatype (it's a header containing various stuff).
I'll at pytables.

# Exploit the operating system's virtual memory manager to get a
"virtual copy" of the entire file in memory
# (This does not actually use any memory until accessed):
virtual_arr = np.memmap(path, np.uint32, "r")
# Get a numpy view onto every 20th entry:
virtual_arr_subsampled = virtual_arr[::20]
# Copy those bits into regular malloc'ed memory:
arr_subsampled = virtual_arr_subsampled.copy()

More information about the NumPy-Discussion mailing list