Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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]

doSomethingwithResults[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
1  
I think you accidentally the sente... ;) Also, it sounds like you need NumberForm –  rm -rf Jul 11 '12 at 8:59
add comment

2 Answers 2

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
add comment

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

Put[results,"results.dat"]
results = Get["results.dat"];
share|improve this answer
add comment

Your Answer

 
discard

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.