# JLD2: How to @load a file from string

**URL:** https://discourse.julialang.org/t/jld2-how-to-load-a-file-from-string/51214
**Category:** General Usage
**Tags:** jld2
**Created:** [December 3, 2020, 5:58pm UTC](https://discourse.julialang.org/t/jld2-how-to-load-a-file-from-string/51214 "2020-12-03T17:58:43Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![neo\_abs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/neo_abs/32/16672_2.png) [@neo\_abs](https://discourse.julialang.org/u/neo_abs)
#### Post date: [December 3, 2020, 5:58pm UTC](https://discourse.julialang.org/t/jld2-how-to-load-a-file-from-string/51214/1 "2020-12-03T17:58:43Z")

</div>

I have series of files saved via JLD2. I want to load them, one by one and do some operations on them.  
Generally I want to do following:

```julia
filename = "somefilename.jld"
@load filename

```

When I do it I get:

```julia
julia> @load filename
ERROR: MethodError: no method matching jldopen(::Symbol)
Closest candidates are:
  jldopen(::AbstractString) at /home/szpieg/.julia/packages/JLD2/ssCUN/src/JLD2.jl:292
  jldopen(::AbstractString, ::Bool, ::Bool, ::Bool) at /home/szpieg/.julia/packages/JLD2/ssCUN/src/JLD2.jl:209
  jldopen(::AbstractString, ::Bool, ::Bool, ::Bool, ::T; fallback, compress, mmaparrays) where T<:Union{Type{IOStream}, Type{JLD2.MmapIO}} at /home/szpieg/.julia/packages/JLD2/ssCUN/src/JLD2.jl:209

```

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [December 4, 2020, 9:07pm UTC](https://discourse.julialang.org/t/jld2-how-to-load-a-file-from-string/51214/3 "2020-12-04T21:07:32Z")

</div>

From the [README.md](https://github.com/JuliaIO/JLD2.jl), “when called with no variable arguments, `@load` requires that the file name is provided as a string literal, i.e., it is not possible to select the file at runtime.”

---

<div class="post-metadata">

### Author: ![JonasIsensee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jonasisensee/32/4704_2.png) [@JonasIsensee](https://discourse.julialang.org/u/JonasIsensee)
#### Post date: [December 4, 2020, 10:24pm UTC](https://discourse.julialang.org/t/jld2-how-to-load-a-file-from-string/51214/4 "2020-12-04T22:24:50Z")

</div>

What @rafael.guerra said is correct.  
If you want to load a list of files then the best thing would be to use the `FileIO.load` API.

---

<div class="post-metadata">

### Author: ![neo\_abs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/neo_abs/32/16672_2.png) [@neo\_abs](https://discourse.julialang.org/u/neo_abs)
#### Post date: [December 5, 2020, 9:31am UTC](https://discourse.julialang.org/t/jld2-how-to-load-a-file-from-string/51214/5 "2020-12-05T09:31:09Z")

</div>

I must have skipped that part. It works great now, thanks.
