How to save Objects/Data in Julia?

How can one save objects in Julia? One easy way to do so it to use the JLD package. The following examples demonstrates how to save data objects in Julia and how to load the once they are saved.

# in case JLD2 is not installed
# Pkg.add("JLD2")
using JLD2

# generate example data objects
n=100
draws = rand(n)

# save data by naming objects
save "data.jld2" draws

#load JLD file
@load "data.jld2" draws

#
# you loaded the objects again in
# your workspace. 
#

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.