h5py provides a model of datasets and groups. The former is basically arrays and the latter you can think of as directories. Each is named. You should look at the documentation for the API and examples:
A simple example where you are creating all of the data upfront and just want to save it to an hdf5 file would look something like:
In : import numpy as np In : import h5py In : a = np.random.random(size=(100,20)) In : h5f = h5py.File('data.h5', 'w') In : h5f.create_dataset('dataset_1', data=a) Out: <HDF5 dataset "dataset_1": shape (100, 20), type "<f8"> In : h5f.close()
You can then load that data back in using: '
In : h5f = h5py.File('data.h5','r') In : b = h5f['dataset_1'][:] In : h5f.close() In : np.allclose(a,b) Out: True
Definitely check out the docs:
Writing to hdf5 file depends either on h5py or pytables (each has a different python API that sits on top of the hdf5 file specification). You should also take a look at other simple binary formats provided by numpy natively such as