Group Abstract Group Abstract

Message Boards Message Boards

2
|
12.1K Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Save expression and load them into another notebook efficiently?

Attachments:
POSTED BY: Markus Schmidt
2 Replies

MX (.mx) is Wolfram Language serialized package format developed by Wolfram Research. It stores arbitrary Wolfram Language expressions in a serialized format optimized for fast loading and preserves anything including the options, etc. For example

res = RandomGraph[{15, 35}, VertexSize -> "BetweennessCentrality"]

enter image description here

Save the fale with DumpSave

DumpSave["res.mx", res];

Now relaunch the kernel:

Exit

And reload the file:

<< res.mx

You will not see result but you have the definition of your variable:

res

enter image description here

Keep in mind that MX files cannot be exchanged between different operating systems or versions of the Wolfram System. In this case you can Export compressed string of any expression:

Compress[res]
Export["res.txt", %]

enter image description here

and Import it back intact:

Uncompress[Import["res.txt"]]

enter image description here

I'd recommend careful reading through: How do I save a variable or function definition to a file?

POSTED BY: Vitaliy Kaurov

That is great, thanks. I think that is what I was looking for. Markus

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