Last active
October 10, 2019 13:03
-
-
Save chr5tphr/a52489c560bf8bd6c4d8f654401ce635 to your computer and use it in GitHub Desktop.
hdf5 tree visualizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import h5py | |
def h5tree(base, key='/', depth=1): | |
if isinstance(base, h5py.Group): | |
return key + '\n' + '\n'.join(' ' * depth + h5tree(obj, key, depth + 1) for key, obj in base.items()) | |
else: | |
blist = str(base[()]).split('\n', maxsplit=1) | |
return '{}: {}'.format(key, blist.pop(0) + (' (...)' if blist else '')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment