HDF5.jl
HDF5.jl copied to clipboard
generic function to get the contents, not the handle
Given a dataset, which may be a scalar or an array, I am wondering what the generic syntax is to get its contents, so that they remain valid after the file is closed. I settled on [] after experimenting, but can't find this in the docs. MWE:
using HDF5
file = tempname() * ".hdf5"
h5open(file, "w") do fid
g = create_group(fid, "g")
g["value"] = 1.0
end
h5open(file, "r") do fid
s = fid["g"]["value"]
s, s[] # invalid, 1.0
end
HDF.jl 0.15.4, Julia 1.6.
The section that describes Reading and writing data does mention read, though I see why it'd be easy to skim over that and not notice.
h5open(file, "r") do fid
s = fid["g"]["value"]
read(s)
end