# Exporting a list as RawData or Data

My problem is quite simple yet I do not seem to figure out the solution to it. I am simply trying to export a list in Mathematica, actually a list of lists of lists etc, something like {{...,{...}},{...}}, but the Head is a list. I want to export this as raw Mathematica symbols so that I can access it later.

Lets take a simple list, say

list = {1,a,Pi};


I am trying:

Export["listname",list,"RawData"]


and also

Export["listname",list,"Data"]


but getting the following error:

Export::infer: Cannot infer format of file listname. >>


This works for other formats such as CSV or TXT.

-
Have you seen DumpSave[]? –  belisarius Mar 11 '14 at 11:12
@belisarius was not aware of DumpSave[] and Save[] which seem to work for my purpose. Still don't understand why Export[] does not work but thanks for the tip! –  someuser_ Mar 11 '14 at 11:30
@Öskå saving as "Text" does not work well in my case because I am actually trying to save lists with many different levels. It would be ideal to just save in Mathematica format. –  someuser_ Mar 11 '14 at 11:36
"data" is an element not a format. The error is because you havent specified a format and none can be inferred from the file name –  george2079 Mar 11 '14 at 12:22
@george2079 Thanks for clearing that but could you be more explicit? How could I save my list without converting it to another data format? I guess the command would be Export["Listname.(some extension)", list, "Data"] –  someuser_ Mar 11 '14 at 12:32

Two options for exporting arbitrary Mathematica expressions are to use Put or to Export to WDX format.

list = {1, a, π};

Put[list, "test.anything"];
Get["test.anything"]

(* {1, a, π} *)

Export["test.wdx", list];
Import["test.wdx"]

(* {1, a, π} *)

-
I've seen people suggest exporting using Compress as well - I don't have the experience to say if this is worth mentioning or not –  Daniel Mar 11 '14 at 15:26
Thanks!! It also works with Save["test",list] and Get["test"] –  someuser_ Mar 13 '14 at 16:20