1
$\begingroup$

I have Mathematica code split into two notebooks. The first part is supposed to run and output a list of numbers into a text file, using Export. The second part uses ReadList to read numbers from the text file, into a list.

I don't like having to convert the list into text and then convert it back to a list. Is there any other way of exporting data which might make it faster for Mathematica to import it again as a list?

Edit:

Suppose the list output from the second notebook has variables and numbers, is storing the result in a text file still ok? For such a case, here is an example of the output list (the way it looks on the text file):

{1}
{75 + 2*Subscript[x, 10] + Subscript[x, 11]}
{-201 - 4*Subscript[x, 10] - 3*Subscript[x, 11] + Subscript[x, 12]}
{157 + 2*Subscript[x, 10] + 3*Subscript[x, 11] - 3*Subscript[x, 12] + Subscript[x, 13]}
{-Subscript[x, 11] + 3*Subscript[x, 12] - 3*Subscript[x, 13] + 10*Subscript[x, 14]}
{-Subscript[x, 12] + 3*Subscript[x, 13] - 12*Subscript[x, 14]}
{-Subscript[x, 13] + 2*Subscript[x, 14]}

If I need to store expressions, which output format is more apt ?

$\endgroup$
  • 1
    $\begingroup$ Or use Put (>>) and Get (<<) with a .m file. $\endgroup$ – m_goldberg Mar 4 '13 at 22:36
  • 1
    $\begingroup$ or Export[filename,Compress@lst] and Uncompress@Import[filename] $\endgroup$ – acl Mar 4 '13 at 23:14
  • 2
    $\begingroup$ Or Export["filename.mx.gz",lst] $\endgroup$ – Ajasja Mar 4 '13 at 23:34
  • 2
    $\begingroup$ Sorry I forgot to mention why. The reason is that the First part which outputs a list is a very CPU-intensive process. Hence I wish to run this part on a different machine, and obtain the output list. I can later use the output list for the Second Part (which is essentially just plots) and run that on my personal computer. $\endgroup$ – Pavithran Iyer Mar 5 '13 at 4:03
  • 2
    $\begingroup$ @PavithranIyer In that case, it's important to remember that DumpSave is not generically compatible between machines. $\endgroup$ – Xerxes Mar 5 '13 at 4:42