Home > Storing Data > Store Data Records in Files

Store Data Records in Files

How to save multiple data records to a file and load them back again.

Let’s say you have a block of name records sort of like this:

group: [
    [1 "Bob" "Smith" 12-Aug-1965 "Seattle"  WA member]
    [2 "Tom" "Able"  20-Feb-1955 "San Jose" CA author]
    [3 "Jen" "Jones" 16-Jun-1972 "New York" NY leader]
    [4 "Sal" "Baker" 25-Oct-1975 "Boston"   MA member]
]

To save all of these to a file:

save/all %group.r group

Take a look at the group.r file in an editor, and you’ll be able to see the same records as above.

To load back the records you saved above:

group: load/all %group.r

Don’t forget to use the /all refinement or you’ll have some problems at times.

Now you have an easy way to save and access data from your programs. This technique even works well for files of more than 100 thousand records!

Advertisements
Categories: Storing Data Tags: , , , ,
  1. No comments yet.
  1. No trackbacks yet.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: