Skip to content

Instantly share code, notes, and snippets.

@Pseudomanifold
Created December 5, 2017 12:18
Show Gist options
  • Save Pseudomanifold/d6d00b2c9be9a8a0c3e770be4f1cbfb7 to your computer and use it in GitHub Desktop.
Save Pseudomanifold/d6d00b2c9be9a8a0c3e770be4f1cbfb7 to your computer and use it in GitHub Desktop.
Creating a simple HDF5 test file with a single group and a single simple data set using the `h5py` Python bindings
#!/usr/bin/env python3
#
# Creates a simple 3x3 HDF5 test file. The file will contain
# a single group and a single *simple* data set. The numbers
# from 1 to 9 will be distributed over the data.
import h5py
f = h5py.File("Simple.hdf5", "w")
d = f.create_dataset("Simple", (3,3), dtype='f')
d[0,0] = 1
d[0,1] = 2
d[0,2] = 3
d[1,0] = 4
d[1,1] = 5
d[1,2] = 6
d[2,0] = 7
d[2,1] = 8
d[2,2] = 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment