January 2019
Intermediate to advanced
390 pages
9h 16m
English
The h5py module is the most popular way to handle HDF5 files in Python. A new or existing HDF5 file can be opened with the h5py.File() function. After the file is open, its groups can simply be accessed by subscripting the file object as if it was a dictionary object. For example, the following code opens an HDF5 file with h5py and then prints the array stored in the /global_power group:
import h5pyhdf5file = h5py.File('pytable_demo.hdf5')ds=hdf5file['/global_power']print(ds)for i in range(len(ds)): print(arr[i])hdf5file.close()
The arr variable prints an HDF5 dataset type:
<HDF5 dataset "global_power": shape (9, 2), type "<f8"> [2.58 0.136] [2.552 0.1 ] [2.55 0.1 ] [2.55 0.1 ] [2.554 0.1 ] [2.55 0.1 ] [2.534 0.096] [2.484 ...
Read now
Unlock full access