Sorry, I am quite new to julia… From looking around, this may be linked to serialization, but I am not sure. In R, I would do (sorry to the R purists, I am one of these “=” <=> “<-” people):
a = 2
saveRDS(a, "example.Rds")
b = readRDS("example.Rds")
I have tried doing the same type of thing in julia
using JLD2
a = 2
@save "example.jld2" a
but then when I @load "example.jld2
, it comes with the name a
attached (even if I go b = @load...
). I don’t want that, I want to assign it to something else right away without manipulation.
To motivate this, one context where this arises is when I am running simulations where the results weigh quite a bit (hundreds of MB to several GB). In the sim code, I use a generic variable name and just change the name of the save file to include some info about the specific sim. In the post-sim code, I just go through the result files, get what info is needed from the file name and process, using again a generic variable name to which I assign the content of whatever file I am using at that point.
I could of course adapt the code to use specific variable names both in and out, but it’s just much easier to go that way. (And saving as csv is either unrealistic in the case of simple variables or not possible for more structured stuff.)
Is there a julia equivalent of my R example?