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
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 Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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