Message Boards Message Boards

0
|
6608 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

How to save a ragged multidimensional array to file and then import it?

Posted 11 years ago
I have an array with a structure like {{a,b},{{c,d},{e,f}}} . It appears to save and import, but when the imported array is examined in FullForm, it is incorrectly structured.  Thus the original array in FullForm looks like List[List[a,b],List[List[c,d],List[e,f]]]  but the imported looks like this in FullForm List["a,b","{{c,d},{e.f}}"]  The indexing to individual elements is incorrect.  Thus MatrixForm[xi[[2,1]]] gives the error message Part::partd: "Part specification \!\({\"{a, b}\", \"{{c, d}, {e, f}}\"}[[2, 1]]\) is longer than depth of object."  I have tried several formats such as Table, List with Export and Import and have also tried Save and Get. It seems that there should be a way to Export or Save in FullForm, but I cannot find it.
POSTED BY: Robert Curl
Posted 11 years ago
 In[1]:= myragged = List[List[a, b], List[List[c, d], List[e, f]]]
 
 Out[1]= {{a, b}, {{c, d}, {e, f}}}
 
 In[2]:= Put[myragged , "myrag.txt"]
 
 In[3]:= diditwork = Get["myrag.txt"]
 
 Out[3]= {{a, b}, {{c, d}, {e, f}}}

In[4]:= diditwork[[2, 1]]

Out[4]= {c, d}
POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract