# Export nested list with complex structure

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?

• ExportString[{ {t, {d1, d2, d3}}}, "Package"] or you use Put or Save Mar 4 '15 at 13:51

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"]