# Writing with NPZ

**URL:** <https://discourse.julialang.org/t/writing-with-npz/95340>\
**Category:** General Usage\
**Created:** [February 28, 2023, 3:14pm UTC](https://discourse.julialang.org/t/writing-with-npz/95340 "2023-02-28T15:14:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [February 28, 2023, 3:14pm UTC](https://discourse.julialang.org/t/writing-with-npz/95340/1 "2023-02-28T15:14:16Z")

</div>

I am trying to write a dictionary element that is a list of lists of Float64. Here is my MWE:

```julia
import NPZ
d = Dict{String, Vector{Vector{Float64}}}("tdnn" => [])
push!(d["tdnn"], [1.,2.,3.])
push!(d["tdnn"], [4.,2.,3.])
NPZ.npzwrite("gordon.npz", d)
NPZ.npzwrite("gordon.npz", d["tdnn"])

```

I have create a dictionary `d` with two `Float64` lists of 3 elements each. Here is the error I get when applying `npzwrite`. Both statements generate the same error:

```julia
ERROR: LoadError: ArgumentError: cannot reinterpret `Vector{Float64}` as `UInt8`, type `Vector{Float64}` is not a bits type
Stacktrace:
 [1] throwbits at ./reinterpretarray.jl:16
 [2] reinterpret at ./reinterpretarray.jl:41
 [3] npzwritearray at /Users/erlebach/.julia/packages/NPZ/UCofn/src/NPZ.jl:360
 [4] npzwrite at /Users/erlebach/.julia/packages/NPZ/UCofn/src/NPZ.jl:437
 [5] top-level scope at /Users/erlebach/src/2022/rude/giesekus/GE_rude.jl/tst.jl:5
 [6] eval at ./boot.jl:368

```

I do not understand why the need for the reinterpretation. What bit type condition is the error referring to? Must the list of lists be converted to an array before `npzwrite` can work properly?  
Thanks.

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [February 28, 2023, 3:33pm UTC](https://discourse.julialang.org/t/writing-with-npz/95340/2 "2023-02-28T15:33:54Z")

</div>

I figured it out. `npzwrite` can only write arrays of Numbers, which excludes strings and Vectors of Vectors. I used `reduce(hcat, list)` to convert my list of lists into a single array.
