Skip to content

Instantly share code, notes, and snippets.

@tkf
Created September 1, 2009 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkf/179044 to your computer and use it in GitHub Desktop.
Save tkf/179044 to your computer and use it in GitHub Desktop.
import h5py
import os
myfile = 'myfile.hdf5'
print "remove %s" % myfile
if os.path.exists(myfile):
os.remove(myfile)
print "write to %s" % myfile
f = h5py.File(myfile, 'w')
dset = f.create_dataset("MyDataset", (100, 100), 'i')
dset[...] = 42
import numpy as np
arr = np.ones((2,3), '=i4')
dset = f.create_dataset('AnotherDataset', data=arr)
subgroup = f.create_group("SubGroup")
dset2 = subgroup.create_dataset('MyOtherDataset', (4,5), '=f8')
dset2 = np.arange( 4*5, dtype=float ).reshape(4,5)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment