# JLD2: triggering the actual writes to file

**URL:** https://discourse.julialang.org/t/jld2-triggering-the-actual-writes-to-file/74981
**Category:** Data
**Tags:** jld2
**Created:** [January 21, 2022, 1:10pm UTC](https://discourse.julialang.org/t/jld2-triggering-the-actual-writes-to-file/74981 "2022-01-21T13:10:07Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Gregstrq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregstrq/32/20620_2.png) [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)
#### Post date: [January 21, 2022, 1:10pm UTC](https://discourse.julialang.org/t/jld2-triggering-the-actual-writes-to-file/74981/1 "2022-01-21T13:10:07Z")

</div>

Let’s say I saved a dataset named “dataset” to “file.jld2”:

```julia
using JLD2, Random
jldopen("file.jld2", "w") do fd
    fd["dataset"] = [randn(100,100) for i=1:100]
end

```

Now, I want to alter one of the entries in the dataset:

```julia
jldopen("file.jld2", "a") do fd
    ds = fd["dataset"]
    ds[1] = randn(100,100)
end

```

- **When is the actual write to the file triggered in the last case? When I do the assignment `ds[1] = randn(100,100)`? Or when the file is closed?**
- **Does it depend on the memory size of the element I am trying to write?** I mean, smaller or larger than buffer.

---

<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: [January 21, 2022, 1:21pm UTC](https://discourse.julialang.org/t/jld2-triggering-the-actual-writes-to-file/74981/2 "2022-01-21T13:21:25Z")

</div>

Hi @Gregstrq,

the `"a"` really means `append`. Arrays are written immediately after assignment  
and it is currently not possible to edit them after that.

This is a limitation of JLD2 (lack of implementation). In principle it might be possible. (Try editing a JLD2 file using the HDF5 libary)

---

<div class="post-metadata">

### Author: ![Gregstrq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregstrq/32/20620_2.png) [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)
#### Post date: [January 21, 2022, 1:24pm UTC](https://discourse.julialang.org/t/jld2-triggering-the-actual-writes-to-file/74981/3 "2022-01-21T13:24:01Z")

</div>

Do you know when the writes are triggered in the case of HDF5?

---

<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: [January 21, 2022, 3:34pm UTC](https://discourse.julialang.org/t/jld2-triggering-the-actual-writes-to-file/74981/4 "2022-01-21T15:34:28Z")

</div>

This usually also happens immediately.

[https://juliaio.github.io/HDF5.jl/stable/#Memory-mapping](https://juliaio.github.io/HDF5.jl/stable/#Memory-mapping)
