1

I've got a really long list that's the result of a complex calculation. I'd like to save it in a way that I can use it again when I start a new session in Mathematica, without having to redo all the previous calculations. Is there a good way to do this? Simply copying and saving it using the short format won't work when you open it with a new kernel. If you copy everything using the 'Show All' option and then assigning it to a new variable, which seems to work, but it's quite lengthy and not very convenient.

enter image description here

hana
  • 2,388
  • 5
  • 19

1 Answers1

3

To answer the comment: DumpSave works by storing the definitions of symbols. These definitions will be restored when you Get the .mx file. So a typical workflow would be:

data = Range[1000000];

DumpSave["datafile.mx", data];

Clear[data]

ByteCount[data]

Get["datafile.mx"]

ByteCount[data]

Note how the Get["datafile.mx"] simply restores the old definition of data. This also works with functions etc.

Sjoerd Smit
  • 23,370
  • 46
  • 75
  • Thank you. I have just figured it out as well. I read somewhere that the saved file may not be compatible with a different computer, operating system, or version of Mathematica. Is there a setting to ensure that it always works on different PCs or versions? – hana Aug 09 '23 at 11:40
  • 1
    No, not for DumpSave. If you need a platform-independent method, use Save, though this might be inefficient for large data. Large data you can store in a file using the WXF format. So it would be something like Export["data.wxf", data] and data = Import["data.wxf"]. – Sjoerd Smit Aug 09 '23 at 11:44