在 julia 中列出 hdf5 文件的字段

List fields of a hdf5 file in julia

julia 有没有办法在不加载数据集的情况下列出 hdf5 文件的字段(包括结构、组、维度)?我没有在 HDF5 包中找到类似于 h5ls -r -f 的东西。谢谢。

不是您要求的 100%,但是使用 printnames 缺少哪些信息?

例如

# make hdf5 file & add two datasets
A = Vector{Int}(1:10)
h5write("bar.h5", "foo", A)
h5write("bar.h5", "2foo", 2A)

i = h5open("bar.h5", "r") # Open it
names(i) 
# 2-element Array{String,1}:
#  "2foo"
#  "foo"
[println(a) for a in i]
# HDF5 dataset: /2foo (file: bar.h5)
# HDF5 dataset: /foo (file: bar.h5)

## Run h5ls
;h5ls "bar.h5"
# 2foo                     Dataset {10}
# foo                      Dataset {10}

这是非常粗略的要点h5_get_structure.jl 对于提供以下输出的 HDF5 文件结构映射:

/Users/TM/Temp/test.h5: HDF5.HDF5File (length 10)
 AcquisitionLog: HDF5.HDF5Group (length 0)
 AddTraces: HDF5.HDF5Group (length 5)
    PTR-Instrument: HDF5.HDF5Group (length 0)
    PTR-Misc: HDF5.HDF5Group (length 0)
    PTR-Reaction: HDF5.HDF5Group (length 0)
    TOFSupply: HDF5.HDF5Group (length 0)
    TofSupply: HDF5.HDF5Group (length 2)
       TwData: HDF5Dataset () 
       TwInfo: HDF5Dataset (28, 2) 
 FullSpectra: HDF5.HDF5Group (length 3)
    MassAxis: HDF5Dataset (100239,) 
    SumSpectrum: HDF5Dataset (100239, 1) 
    TofData: HDF5Dataset (100239, 1, 1, 6000) 
 PTR-Concentration: HDF5.HDF5Group (length 0)
 PTR-Peaktable: HDF5.HDF5Group (length 2)
    Data: HDF5Dataset (317, 8) Float64
    Info: HDF5Dataset (317,) 
 PTR-PrimaryIonSettings: HDF5.HDF5Group (length 0)
 PTR-Transmission: HDF5.HDF5Group (length 0)
 PeakData: HDF5.HDF5Group (length 2)
    PeakData: HDF5Dataset (317, 1, 1, 6000) 
    PeakTable: HDF5Dataset (4, 317) Float64
 RawData: HDF5.HDF5Group (length 1)
    HPTDC: HDF5.HDF5Group (length 0)
 TimingData: HDF5.HDF5Group (length 1)
    BufTimes: HDF5Dataset (6000,)