JuliaIO / JLD2.jl

HDF5-compatible file format in pure Julia
Other
549 stars 85 forks source link

List groups? #419

Closed jlchan closed 1 year ago

jlchan commented 1 year ago

Is there a way to list the root-level groups in a loaded JLD2 file?

JonasIsensee commented 1 year ago

Hi @jlchan ,

can you please make your question a bit more specific? A JLD2 file only has one single "root" group, namely "/".

jlchan commented 1 year ago

Apologies - yes, let me try. Suppose I have a file with structure

julia> file
JLDFile /Users/jessechan/Desktop/ES_CNS_splitting_paper/code/test.jld2 (read/write)
 ├─🔢 group_3
 ├─📂 group_1
 │  ├─🔢 subgroup_1
 │  └─🔢 subgroup_2
 └─📂 group_2
    ├─🔢 subgroup_1
    └─🔢 subgroup_2

is there a command which will list group_1, group_2, group_3?

Thanks!

JonasIsensee commented 1 year ago

Is this what you are looking for? ̀``` julia> using JLD2

julia> save("test.jld2", "a/c", 1, "b",2)

julia> f = jldopen("test.jld2") JLDFile /home/isensee/test.jld2 (read-only) ├─🔢 b └─📂 a └─🔢 c

julia> keys(f) 2-element Vector{String}: "b" "a"

jlchan commented 1 year ago

Yes, thank you!