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

I'm generating a long table of list of the form:



Export["PN.dat", PN, "Table"]

Seems to do the job of exporting, but then using:

PN = Import["PN.dat", "Table"] or PN = ReadList["PN.dat"]

Can't reconstruct the same List, the first way considers the imaginary number i as something else "I", while the second one returns insane data like:

{{-1., -2.6464*10^-40, 0. + 2.76621*10^18 I}, {-0.129967...

Any ideas how to do this right? (Using ToExpression Returns $Faild)

share|improve this question
Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2)Read the FAQs! 3) When you see good Q&A, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. ALSO, remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign` – chris Dec 1 '12 at 14:16
up vote 2 down vote accepted

First, the root of $-1$ is represented as I, not i.

In any case, the technique I use to export arbitrary data structures is to compress, save, load and uncompress:

PN = {{1, 2, 1 + I}, {3.5, 2.6 - 0.8*I, 2}}
Export["~/Desktop/PN.txt", Compress@PN]
{#, Im@#} &@Uncompress@Import@"~/Desktop/PN.txt"

(*{{{1, 2, 1 + I}, {3.5, 2.6 - 0.8 I, 2}}, {{0, 0, 1}, {0, -0.8, 0}}}*)
share|improve this answer
Congrats on 10k rep ! – Artes Dec 4 '12 at 3:53
@Artes thank you! – acl Dec 4 '12 at 9:56

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.