Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Continuation of this question: How to export if I need to have two extensions instead of one. E.g., in the previous case one can generate lists labeled L[1], L[2],.....and so on using a loop. But if I have 2 loops and hence two variables and the lists are labeled L[1,1], L[1,2],… then L[2,1], L[2,2],… How do I export them in wdx format?

share|improve this question

Make some 2D data:

data = RandomInteger[Range@2, {5, 3}];

Create a series of strings to represent the indices of the elements of data:

Array[ToString[#1] <> "_" <> ToString[#2] &, Dimensions@data]

{{"1_1", "1_2", "1_3"}, {"2_1", "2_2", "2_3"}, {"3_1", "3_2", "3_3"}, {"4_1", "4_2", "4_3"}, {"5_1", "5_2", "5_3"}}

Then just add those strings into whatever basename and extension you are using for your files and use that with Save, DumpSave or Export.

share|improve this answer
Since you used Dimensions, perhaps StringJoin[Riffle[ToString/@{##}, "_"]]& would be more universal. – VF1 Dec 15 '12 at 5:43
@VF1 That looks significantly different enough to be an answer :) – image_doctor Dec 15 '12 at 10:31

If you have n-dimensional data, then create the names:

names = Array[StringJoin[Riffle[ToString/@{##}, "_"]]&, Dimensions[data]]

Then export each one:

MapThread[Export[#1 <> ".wdx", #2] &, {names, data}, Depth@data - 1]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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