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/179045 to your computer and use it in GitHub Desktop.
Save tkf/179045 to your computer and use it in GitHub Desktop.
import h5py
ispace = ' ' * 2
def see_dataset(dset, indent=0):
sp = ispace * (indent+1)
vstr = str(dset.value)
print "\n".join([sp + vi for vi in vstr.split('\n')])
def see_group(group, indent=0):
sp = ispace * indent
for (name, value) in group.iteritems():
if isinstance(value,h5py.Dataset):
print sp + name + ":"
see_dataset(value, indent+1)
elif isinstance(value,h5py.Group):
print sp + name + ":"
see_group(value, indent+1)
def see_hdf5(path):
f = h5py.File(path)
see_group(f)
return f
see_hdf5('myfile.hdf5').close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment