# Save Model Outputs

**URL:** https://discourse.julialang.org/t/save-model-outputs/90465
**Category:** Optimization (Mathematical)
**Created:** [November 18, 2022, 4:45pm UTC](https://discourse.julialang.org/t/save-model-outputs/90465 "2022-11-18T16:45:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Yuri\_Masakazu\_Mizusa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuri_masakazu_mizusa/32/36504_2.png) [@Yuri\_Masakazu\_Mizusa](https://discourse.julialang.org/u/Yuri_Masakazu_Mizusa)
#### Post date: [November 18, 2022, 4:45pm UTC](https://discourse.julialang.org/t/save-model-outputs/90465/1 "2022-11-18T16:45:51Z")

</div>

Hi,  
I am running a small model several times (1000 to be more precise) and for each run I need to store the results. Usually I turn it to a DataFrame and save as a csv. But in this case I do not want to save 1000 csvs. I understand that this question is not exactly optimization but I wanted to know if there is any alternative in JuMP for this case. In R you can use RDS so I was trying to use jld, but I am not able to save and load the save data.

```julia
# Dataframe with model results 
df = DataFrame(variable = [1, 2, 3, 4, 5], 
               value = [800, 250, 700, 1400, 120]
               )

vec_dfs = []

# Simulated sequential results
push!(vec_dfs,df)
push!(vec_dfs,df)

save("/home/myfile.jld", "vec_dfs", vec_dfs)

d = load("/home/myfile.jld")

```

During the save I get:

```julia
┌ Warning: `object_info(obj::Union{File, Object})` is deprecated, use `API.h5o_get_info1(checkvalid(obj))` instead.
│ caller = typeindex(parent::JLD.JldFile, addr::UInt64) at jld_types.jl:812
└ @ JLD ~/.julia/packages/JLD/6OyJe/src/jld_types.jl:812
error parsing type string @where(Core.AbstractArray{#s77,1},#s77)
Error encountered while load File{FileIO.DataFormat{:JLD}, String}("/home/yuri/myfile.jld").

```

For simple variables I am able to sabe the jld.

I also tried to save as txt but had a similar problem trying to read.  
Am I doing something wrong? Or can you help me with alternatives?  
Thanks!

---

<div class="post-metadata">

### Author: ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)
#### Post date: [November 20, 2022, 6:07pm UTC](https://discourse.julialang.org/t/save-model-outputs/90465/2 "2022-11-20T18:07:40Z")

</div>

I don’t know what the problem is with `load`, but it’s likely that `vec_dfs = []` is a `Vector{Any}`. I guess it needs to be a vector of concrete types? Try `vec_dfs = DataFrame[]`.

Otherwise though, why not create one large DataFrame with a `run_id::Int` column and save that to a CSV (or a database)?

---

<div class="post-metadata">

### Author: ![Yuri\_Masakazu\_Mizusa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuri_masakazu_mizusa/32/36504_2.png) [@Yuri\_Masakazu\_Mizusa](https://discourse.julialang.org/u/Yuri_Masakazu_Mizusa)
#### Post date: [November 21, 2022, 11:27pm UTC](https://discourse.julialang.org/t/save-model-outputs/90465/3 "2022-11-21T23:27:49Z")

</div>

Hi,  
Thanks for the answer, I was trying to avoid one long file so I opted not to use the stacked csv. Also I am more used to work with a list o tables.  
I did manage no save by the following way:

```julia
f = open("/home/resultados.jl", "w")
print(f, vec_results)
close(f)

```

,and reading by:

```julia
vec_res=include("/home/resultados.jl")

```

The only thing I had to do was change from DataFrame to Array and it worked fine.  
Thanks!
