2
$\begingroup$

I have a list that looks like this

l = {elem1, elem2, ...} 

Where elem_={t, {d1,d2,d3} }

How can I export it? I tried Export["data.txt",l,"Table"], but it puts a whole elem on the same line so the nested structure can't be restored. I suppose I could write a function to parse the txt file, but what is the correct way to do this?

$\endgroup$
1
  • $\begingroup$ ExportString[{ {t, {d1, d2, d3}}}, "Package"] or you use Put or Save $\endgroup$ Commented Mar 4, 2015 at 13:51

1 Answer 1

4
$\begingroup$

You can do, for example, the following:

list = Table[{i, {2^i, 3^i, 5^i}}, {i, 1, 10}] 

then

Export["test.m", list] 

and

Clear @ list 

and finally

list = Import["test.m"] 
$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.