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$ 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$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.