简体   繁体   中英

Python hdf5 file with tables: How to read hdf data where the title includes blank characters

How can I read a hdf5 table datablock as:

domains = h5.root.name with blank

this is not possible, but maybe with special signs?

The code in your question looks like pytables (not h5py). However, you can read objects with spaces in the name with both packages.
Here are the ways to access a table or dataset using each package. Example assumes 'name with blank' is a dataset. The code still works to get a group object, but you can't get an array from a group.

h5py method:

domains_ds = h5['name with blank'] # returns dataset object
domains_arr = h5['name with blank'][()] # returns numpy array object

pytables method:

domains_ds = h5.get_node('name with blank') # returns table or array object as appropriate 
domains_arr = h5.read('name with blank') # returns numpy array object 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM