h5py: deep dataset access - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: h5py: deep dataset access (/thread-22764.html) |
h5py: deep dataset access - paul18fr - Nov-26-2019 All I'm looking in a way to list and record hdf5 file content (full path and dataset number/names) into lists; digging into internet, I've found the following ways to print them, but how to record them? I tried to append the list by giving it as a second argument, but it fails; could you help? Thanks Paul def print_attrs(name, obj): print(name) print(obj) for key, val in obj.attrs.items(): print("{}: {}" .format(key, val)) with h5py.File('myfile.h5', 'r') as f: group_names = list(h5.keys()) f.visititems(print_attrs) f.visit(print) RE: h5py: deep dataset access - paul18fr - Nov-26-2019 finally I got it into a pdf file: DatasetList = [] f.visit(DatasetList.append) RE: h5py: deep dataset access - paul18fr - Nov-28-2019 in addition to it, additional procedures in stackoverflow Maybe it can help Paul |