'Extracting member names from HDF5 compound datasets with h5py
I am trying to extract compound datasets from multiple .hd5 files. Initially, I used HD5View 2.9, which lets you open up datasets as tables and save them as .txt files; however, it does not save the column headers, i.e., "sensor," "framerate," etc as in this image:
https://i.imgur.com/5zRvpm8.png
So now I am attempting to write an h5py script that will read in these datasets along with the column headers, also known as "member names," but it seems to be more complicated than I was expecting. I have successfully written scripts that extract simple datasets containing only integers, in which the column headers are just indices I don't care about. But I am not even sure how to gain access to member names using h5py.
Solution 1:[1]
http://docs.h5py.org/en/latest/high/attr.html
when you use .keys()
,
you can get "KeysView( < HDF5 group "../path" (n members)> )"
After that,
list(KeysView(< HDF5 group "../path" (n members) >)) --> get memebers name
Solution 2:[2]
Field names are found in the dtype, same as in numpy structured arrays. Credits to @hpaulj
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | developerick |
Solution 2 | Jan Struhar |