Message Boards Message Boards

0
|
1310 Views
|
4 Replies
|
4 Total Likes
View groups...
Share
Share this post:

How store ResourceObject on local machine?

I evaluate ResourcObject["someName"], where the object i question is somewhere in the Cloud, I have access to it in the current Mathematica session. But how can I get it to be stored on my local machine, so that I subsequently have access to it there, without resorting to the Cloud again?

And where exactly does that object get stored on the local machine? (Presumably somewhere in $UserBaseDirectory?

Consider the preceding questions in the situation, for example, with:

 ResourceObject["Sample Data for Query Book"]
POSTED BY: Murray Eisenberg
4 Replies
Posted 5 months ago

Hi Murray,

ResourceObject + ResourceData will cache the data locally.

ro = ResourceObject["Sample Data for Query Book"]
rd = ResourceData["Sample Data for Query Book"]

Quit[]

(* Use the locally cached data *)
rd = ResourceData["Sample Data for Query Book"]

(* Location of cached data *)
ro["ResourceLocations"]
POSTED BY: Rohit Namjoshi

But how do I readily access the data on another occasion, after I've quit Mathematica and then reopened Mathematica?

POSTED BY: Murray Eisenberg
Posted 5 months ago

Hi Murray, One way to do this is to assign the ResourceObject to a symbol, and then export the symbol to a .mx file in a directory of your choice. The value of the ResourceObject can then be reloaded as needed. For example:

SetDirectory[NotebookDirectory[]];

sampleDataForQueryBook = ResourceObject["Sample Data for Query Book"];

DumpSave["Query data.mx", sampleDataForQueryBook];

Clear@sampleDataForQueryBook

sampleDataForQueryBook

(* sampleDataForQueryBook *)

<< "Query data.mx"

sampleDataForQueryBook

(*ResourceObject[Name: Sample Data for Query Book ยป 
Type: DataResource  \[SpanFromLeft]
Description: Data to support the Wolfram Media book Query: Getting \
Information from Data with...   \[SpanFromLeft]

]*)
POSTED BY: David Keith
  1. A little note that one must first, of course, save the current notebook before setting the SetDirectory.

  2. This method is not as general as one might wish, since the .mx file is saved in the current notebook's directory and not in $UserBaseDirectory or, perhaps better, in ~/Library/Wolfram/Objects.. `.

POSTED BY: Murray Eisenberg
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract