# Exporting/Importing a Table of complex numbers

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

PN={{1,2,1+i},{3.5,2.6,2}...},{...},...

Using:

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) - 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 ## 1 Answer 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:

ClearAll@PN;
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}}}*)
`
-
Congrats on 10k rep ! –  Artes Dec 4 '12 at 3:53
@Artes thank you! –  acl Dec 4 '12 at 9:56