Hey ! I am looking for the optimal way of saving a vector of vectors in which each vector has different dimensions. The major problem is that I cannot save it as a df then get it as a CSV file…
Thanks for your help !
1 Like
You can use JLD2.jl. A quick example:
julia> import JLD2
julia> x = [[1,2,3], [1,2], [1,2,3,4]]
3-element Vector{Vector{Int64}}:
[1, 2, 3]
[1, 2]
[1, 2, 3, 4]
julia> JLD2.save_object("test.jld2", x)
julia> y = JLD2.load_object("test.jld2")
3-element Vector{Vector{Int64}}:
[1, 2, 3]
[1, 2]
[1, 2, 3, 4]
julia> x == y
true
2 Likes
Another possibility is JLSO.jl:
julia> using JLSO
julia> x = [[1, 2, 3], [1, 2], [1, 2, 3, 4]]
3-element Vector{Vector{Int64}}:
[1, 2, 3]
[1, 2]
[1, 2, 3, 4]
julia> JLSO.save("test.jlso", :myarray => x)
julia> loaded = JLSO.load("test.jlso")
Dict{Symbol, Any} with 1 entry:
:myarray => [[1, 2, 3], [1, 2], [1, 2, 3, 4]]
julia> y = loaded[:myarray]
3-element Vector{Vector{Int64}}:
[1, 2, 3]
[1, 2]
[1, 2, 3, 4]
julia> x == y
true
1 Like
Thank you !
1 Like