-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
string interpolation in @load #88
Comments
This is basically the same issue as #83. The file name needs to be known at compile time to put the variables into the calling scope. |
I see, but this brings me to another doubt: is it possible to read all variables and place them in a Dict ? From what I've been using so far, that would be great, so one could do vars = load(fName)
@show vars["myvar"] # should print the variable "myvar" loaded from fName or maybe this functionality exists and I totally missed it. |
Yes, we need this. I swear someone implemented what seemed to be a nice package on top of JLD that had this and more, but I am having trouble finding it. But presumably at least something like |
I have an implementation of something in that direction here: https://github.com/rened/DictFiles.jl |
Thanks, @rened! |
Great. I guess something like this should work: function dictLoad( filename::String )
D = Dict{String,Any}()
readexprs = Array(Expr, 0)
vars = Array(Expr, 0)
f = jldopen(filename)
nms = names(f)
for n in nms
obj = f[n]
if isa(obj, JLD.JldDataset)
D[n] = read(f,n)
end
end
close(f)
return D
end But to create a meaningful PR:
EDIT:
data = dictLoad("test.jld")
@show data[:varName] this assumes no spaces in var names, of course. |
Looks good to me. As you noticed, this will only work for top-level datasets. Regarding your questions:
We may find that the default display of dictionaries is a bit inconvenient. If desired, I have a |
About descending into groups, I am not familiar with HDF5 but I think I get the idea. I suppose that we can first target the 'most common usage' of top-level datasets. About symbols, it is just a shortcut. I would add a keyword argument for using symbols, which by default would be false, so that by default we don't get in trouble with symbols. The display function would be great, I agree that the default implementation would be messy to interpret. I will get back to this soon and create a PR. |
I may be doing something wrong, but
throws
while the following works fine
The text was updated successfully, but these errors were encountered: