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 JLD is not installed
# Pkg.add("JLD")
using JLD

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

# save data by naming objects
save("data.JLD","numberObs",n,"draws",draws)

#load JLD file
load("data.JLD")

#
# you loaded the objects again in 
# your workspace. In addition, the 
# the object "n" is now named "numberObs"
# 
Advertisements

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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.