I want to export my_data and then import them back again in exactly the same data structure as the one they had when they were initially generated.

mydata = Table[{σ, RandomVariate[NormalDistribution[0, σ]]}, {σ, 1, 2}, {100}]

I say exactly, because no matter what I have tried based on the online documentation, when I import the exported data, the structure is not valid for plotting them using:

  PlotRange -> {{0, 10}, {-20, 20}, {0, All}},
  AxesLabel -> (Text[Style[#, Italic, 14]] & /@ {"a", "b", "c"})]

(plotting works with the initially generated data)

Could you provide here with the correct export and import commands?

  • $\begingroup$ Underscore should not appear in a Mathematica symbol. Use mydata instead of my_data. $\endgroup$ Oct 4, 2020 at 15:18
  • $\begingroup$ Thanks for mentioning. Though in practice I am not using. The variable is simply "data". Hence, the question still holds. $\endgroup$
    – Gouz
    Oct 4, 2020 at 15:21

2 Answers 2


You can use Put (>>) and Get (<<).

mydataImported = <<filename

Alternatively, exporting and importing as a spreadsheet



Generating and exporting the data

  mydata = Table[{σ, 
     RandomVariate[NormalDistribution[0, σ]]}, {σ, 1, 2}, {100}]];

The imported data is

mydata2 = Import["/Users/roberthanlon/Downloads/mydata.xls"];

The data is equivalent

mydata == mydata2

(* True *)

Although not identical

mydata === mydata2

(* False *)

Generating the histograms

{hg1, hg2} = 
 Show[Histogram3D[#, PlotRange -> {{0, 10}, {-20, 20}, {0, All}}, 
     AxesLabel -> (Text[Style[#, Italic, 14]] & /@ {"a", "b", 
         "c"})]] & /@ {mydata, mydata2}

enter image description here

The histograms are identical

SameQ @@ {hg1, hg2}

(* True *)

Your Answer

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

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