# Incrementally growing datafield with JLD

**URL:** <https://discourse.julialang.org/t/incrementally-growing-datafield-with-jld/7919>\
**Category:** General Usage\
**Tags:** jld\
**Created:** [December 22, 2017, 1:52pm UTC](https://discourse.julialang.org/t/incrementally-growing-datafield-with-jld/7919 "2017-12-22T13:52:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [December 22, 2017, 1:52pm UTC](https://discourse.julialang.org/t/incrementally-growing-datafield-with-jld/7919/1 "2017-12-22T13:52:10Z")

</div>

Let’s say I have a matrix stored in a file and I want to add columns over time. I want to add them in chunks so that I do not open/close the file all the time and I also want compression.

HDF5 allows me to do so for basic types (i.e. eltype Float64) with an initial `d_create` and `set_dims!` magic afterwards (see [doc](https://github.com/JuliaIO/HDF5.jl/blob/master/doc/hdf5.md) and search for `set_dims!`). Of course, I can do exactly the same for JLD files, because they are basically HDF5.

Excerpt from HDF5.jl doc:

```julia
b = d_create(fid, "b", Int, ((1000,),(-1,)), "chunk", (100,)) #-1 is equivalent to typemax(Hsize)
set_dims!(b, (10000,))
b[1:10000] = collect(1:10000)

```

However, let’s say the matrix has eltype Complex128. Plain HDF5 doesn’t know complex numbers. This is where JLD is convenient. But I can’t apply the `d_create`/`set_dims!` strategy here because those functions are inherited from HDF5.jl and don’t allow for datatype Complex128.

Is there a way to get this (incrementally growing datafield) done nicely with JLD?
