Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is probably an easy question: I am exporting the results from a longer calculation into a dat-File, then I set the cell to non-evaluatable and put an Import in front, so I can later work with the results, even after closing and reopening the notebook:

results = Import["results.dat"]

(non-evaluatable) results = makeLongCalculation[parameters]
(non-evaluatable) Export["results.dat",results]


(Is there a more elegant way?)

Now, I have the problem that complex numbers are imported as strings. My results are typically of the form {{0.01,3*10^-6+5*10^-4*I},...}. Is there any more straightforward way than to apply something like ToExpression to the Import? I feel that native Mathemat

share|improve this question
I think you accidentally the sente... ;) Also, it sounds like you need NumberForm – R. M. Jul 11 '12 at 8:59
up vote 4 down vote accepted

Or in concise notation:

results >>   "results.dat";
results = << "results.dat";

You can automate the process slightly, by reading the data in if the file exists and results isn't defined or writing it out otherwise.

If[Head@results === Symbol && FileExistsQ["complex.dat"], 
 results = << "complex.dat", results >> "complex.dat"]
share|improve this answer
As I would like to maintain control (calculation may take8h on 8cores), I will not use the automation here, but nevertheless nice idea. Thanks. (Also to Simon.) – mcandril Jul 11 '12 at 10:06
@mcandril Thanks, it may be that someone here can reduce that computation time for you. – image_doctor Jul 11 '12 at 14:45
It is basically just adding up A LOT of complex numbers, for unaproximated Frenel-Huygens principle. I am not sure how much optimisation potential there is and how to pose the question so its relevant. – mcandril Jul 12 '12 at 15:54

You could use Put and Get instead of Export and Import.

results = Get["results.dat"];
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.