【问题标题】:How to access all the data saved in a h5py file如何访问保存在 h5py 文件中的所有数据
【发布时间】:2018-01-23 03:21:51
【问题描述】:

我将一些 numpy 数组保存到一个 h5py 文件中,不同的名称对应于不同的数据集。假设我不知道那些数据集名称,如何在读取 h5py 文件后访问保存的数据。例如:

f = h5py.file('filename','w')
f.create_dataset('file1',data=data1)
.... 

F = h5py.file('filename','r')
#next how to read out all the datasets without knowing their names in a prior

【问题讨论】:

    标签: python


    【解决方案1】:
    filenames = list(F.keys()) #which contains all the dataset names
    data1 = F[filenames[0]].value.astype('float32') 
    ...
    

    另见帖子How to know HDF5 dataset name in python

    【讨论】:

      猜你喜欢
      • 2017-12-06
      • 1970-01-01
      • 1970-01-01
      • 2017-05-01
      • 2019-01-04
      • 2011-07-20
      • 2020-09-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多