how to export HDF5 file to NumPy using H5PY?

h5py, hdf5, numpy, python

Solution

`h5py` already reads files in as numpy arrays, so just:

with h5py.File('the_filename', 'r') as f:
    my_array = f['array_name'][()]

The `[()]` means to read the entire array in; if you don't do that, it doesn't read the whole data but instead gives you lazy access to sub-parts (very useful when the array is huge but you only need a small part of it).

Problem

I have an existing hdf5 file with three arrays, i want to extract one of the arrays using h5py.

Original source