Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Exporting/Importing Nested List' topicStudent Support Forum > General > Archives > "Exporting/Importing Nested List"

< Previous CommentHelp | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
10/23/12 8:06pm

It looks like Export is happy to deal with constants, vectors and matricies, but when the list gets deeper it appears to start turning bits into strings.

In[1]:= test={{{1,2},3},{3,4}};
Export["out.dat",test,"String"];
FullForm[Import["out.dat"]]

Out[3]//FullForm= List[List["{{{1,","2},","3},","{3,","4}}"]]

But two dimensional matricies work

In[4]:= test={{5.7,4.3},{-1.2,7.8}};
Export["out.dat",test];
FullForm[Import["out.dat"]]

Out[6]//FullForm= List[List[5.7`,4.299999999999999`],List[-1.2`,7.799999999999999`]]

Here is a workaround IF you are using this for correctly formatted lists of any depth.

In[7]:= test={{{1,2},3},{3,4}};
Put[test,"out.dat"];
Get["out.dat"]

Out[9]= {{{1,2},3},{3,4}}

In[10]:= FullForm[%]

Out[10]//FullForm= List[List[List[1,2],3],List[3,4]]

URL: ,

Subject (listing for 'Exporting/Importing Nested List')
Author Date Posted
Exporting/Importing Nested List Andreas 10/23/12 04:43am
Re: Exporting/Importing Nested List Bill Simpson 10/23/12 8:06pm
< Previous CommentHelp | Reply To Comment | Reply To Topic