MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Alternative to DumpSave

  • To: mathgroup at smc.vnet.net
  • Subject: [mg116921] Re: Alternative to DumpSave
  • From: James Stein <mathgroup at stein.org>
  • Date: Fri, 4 Mar 2011 03:41:10 -0500 (EST)

It's a bit tedious, but you can build up strings to define each variable
from scratch, concatenate them (with line feeds for legibility), then export
them to a notebook.  For example, for a single variable, something like
this:

s = ToString[var1] <> "[" <> descriptor <> "]={" <> ToString[something] <>
"};\n";
Export[sj, filename"];

where the final 'sj' would be a StringJoin of a bunch of similar strings
like 's'. Details will vary according to your application. It may help to
have a list of your descriptors, so that building the set of strings could
be done via Map or in a loop. (From your description, I assume that
variables such as 'var1', shorn of the "["descriptor"]", are not defined, so
that ToString[var1] will yield the string "var1"; if this is not the case,
that's just one more detail to change.)

What you lose in file size expansion you gain in legibility and
cross-platform workability. Such files can also be automatically loaded,
evaluated, and closed from another notebook.


On Thu, Mar 3, 2011 at 2:59 AM, Thomas Muench <thomas.muench at gmail.com>wrote:

> Dear Mathgroup,
>
> Can anybody suggest an elegant alternative to the DumpSave[] command?
> I like DumpSave because it gives a compact (=small file size)
> representation of variables and their definitions. However, the format
> is not portable across systems. For example, I cannot load the
> DumpSave-ed data from a Win-XP system into a Win-7-64bit system.
>
> To describe the problem more explicitely: I have created data in a
> lengthy computation that is saved in a couple of variables. These
> variables each have relatively complex definitions, for example many
> variations of var1["descriptor"]={something}. I then save the
> definitions of these variables with DumpSave like that:
> DumpSave["filename.mx",{var1,var2,var3}];
> In a later session, I can re-load them with Get["filename.mx"], which
> works wonderfully and amazingly fast.
>
> How can I achieve something equivalent accross systems?
>
> This in in Mathematica 8.
>
> Thank you!
> thomas
>


  • Prev by Date: Re: Patterns with conditions
  • Next by Date: evaluation-- one or many levels, your thoughts?
  • Previous by thread: Re: Alternative to DumpSave
  • Next by thread: Re: Alternative to DumpSave