1
$\begingroup$

I have a code that writes datas into file using PutAppend[]. A simple form of the code is written below,

SetDirectory[
  CreateDirectory["/home/Desktop/results"]];
outfile = "data1.txt"
Put[outfile];
Do[
prob=f[i],
PutAppend[prob,outfile],{i, 1, 100000}];

Now the problem is that the numbers in output file has form like 2.1337598830647752*^-6. I need to do some other calculation using the output data in mathematica again. I know one can use "CSV" for exporting data, but is there a way to control the format inside PutAppend in a way that it can simply exported into mathematica for other calculation? I belive that the * and ^ will introduce problem into calculations.

$\endgroup$
  • 1
    $\begingroup$ Why do you think there will be a problem? That's a valid shorthand for 2.1337598830647752*10^-6 $\endgroup$ – ciao May 6 '15 at 23:14
  • $\begingroup$ Hi' I started to do calculation and it does not do it correctly,so for example it prints the result as, 2.1337598830647752*^-6*Log[ 2.1337598830647752*^-6] instead of giving a final result, but when I remove the ^ and * it works perfectly... $\endgroup$ – setareh May 7 '15 at 20:46
  • $\begingroup$ It sounds like it is reading it back in as a string. Have you looked at DumpSave and the .mx file format. That will keep the data binary instead of converting it to text. $\endgroup$ – Edmund May 12 '15 at 21:36
1
$\begingroup$

well, I found a another solution,instead of changing the writing format, one need to convert the datas using ToExpression[data1.txt]....

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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