JuliaIO / JLD2.jl

HDF5-compatible file format in pure Julia
Other
560 stars 92 forks source link

reading individual variables from a JLD2 files #378

Closed avigliotti closed 2 years ago

avigliotti commented 2 years ago

Hi,

is there a way to read specific variables fro a JLD2 files that contains many variables some of which are quite large, which means that reading the entire file can take long?

the file has been saved through FileIO as

FileIO.save(sFileName, Dict("x"=>x, "y"=>y, "z"=>z))

ideally, I would like to be able to do something like

x = FileIO.load(sFileName, "x")

similar to what you can do in matlab

lhupe commented 2 years ago

yes, that should work exactly as you suggested

julia> FileIO.save("foo.jld2", Dict("x"=>[1,2,3,4], "y"=>[5,6,7,8], "z"=>[9,10,11,12]))
julia> FileIO.load("foo.jld2", "x")
4-element Vector{Int64}:
 1
 2
 3
 4
avigliotti commented 2 years ago

that's great thanks! I din't see it in the documentation and I assumed was not there