how to export HDF5 file to NumPy using H5PY? how to export HDF5 file to NumPy using H5PY? python python

how to export HDF5 file to NumPy using H5PY?


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).


For this question it is way overkill but if you have a lot of things like this to do I use a package SpacePy that makes some of this easier.

datamodel.fromHDF5() documentation This returns a dictionary of arrays stored in a similar way to how h5py handles data.