# Export/import color matrix

**URL:** <https://discourse.julialang.org/t/export-import-color-matrix/79861>\
**Category:** New to Julia\
**Tags:** colors, import-data\
**Created:** [April 22, 2022, 6:13pm UTC](https://discourse.julialang.org/t/export-import-color-matrix/79861 "2022-04-22T18:13:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmed](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@ahmed](https://discourse.julialang.org/u/ahmed)\
**Post date:** [April 22, 2022, 6:13pm UTC](https://discourse.julialang.org/t/export-import-color-matrix/79861/1 "2022-04-22T18:13:50Z")

</div>

I have a matrix of colors of the type RGB{float 64}. I’d like to export this matrix from julia to a file and then import it back to julia to do further analysis. I tried using DelimitedFiles this way:  
writedlm(“colors.txt”, colors) to export the file and then  
Array(readdlm(“colors.txt”)) to import it.  
The problem is this has the data in a text form and I wanna convert to colors. Is there a way to convert it to colors? or should I have used a different package than Delimited Files?  
Thanks for help!

---

<div class="post-metadata">

**Author:** ![icweaver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/icweaver/32/45764_2.png) [@icweaver](https://discourse.julialang.org/u/icweaver)\
**Post date:** [April 22, 2022, 6:32pm UTC](https://discourse.julialang.org/t/export-import-color-matrix/79861/2 "2022-04-22T18:32:24Z")

</div>

I think [JLD2.jl](https://github.com/JuliaIO/JLD2.jl) might be a good option:

```julia
julia> using Colors, JLD2

julia> x = rand(RGB, 3, 2)
3×2 Array{RGB{Float64},2} with eltype RGB{Float64}:
 RGB{Float64}(0.8795,0.997088,0.0300252) RGB{Float64}(0.0860507,0.487816,0.772049)
 RGB{Float64}(0.507044,0.239653,0.166532) RGB{Float64}(0.815468,0.1354,0.230995)
 RGB{Float64}(0.847003,0.0561504,0.165049) RGB{Float64}(0.712974,0.591226,0.854261)

julia> save_object("color_file.jld2", x)

julia> x2 = load_object("color_file.jld2")
3×2 Array{RGB{Float64},2} with eltype RGB{Float64}:
 RGB{Float64}(0.8795,0.997088,0.0300252) RGB{Float64}(0.0860507,0.487816,0.772049)
 RGB{Float64}(0.507044,0.239653,0.166532) RGB{Float64}(0.815468,0.1354,0.230995)
 RGB{Float64}(0.847003,0.0561504,0.165049) RGB{Float64}(0.712974,0.591226,0.854261)

julia> x == x2
true

```

There should also be more ways to save/load your data here: [Basics · Julia Data Format](https://juliaio.github.io/JLD2.jl/stable/#Reading-and-writing-data)
