Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Bug introduced in 7.0 and fixed in 8.0


I am using Mathematica 7 and I need to export a table of data and the corresponding x and y arrays. I would like to format them as a single file, say grid.h5, and need the arrays named for import in a different program. Unfortunately, applying the command:

Export["MGfunc.h5", {data, x1, y1}, {"Datasets", {"MGfunc", "x", "y"}}]

only seems to save the last array in the file MGfunc.h5.

Does anyone know how to get this working using the HDF5 format?

Here is an example:

ki = N[Table[i, {i, 0, 3}]] (* -> {0., 1., 2., 3.} *)
kj = N[Table[j, {j, 0, 3}]] (* -> {0., 1., 2., 3.} *)
testgrid = Table[ki*kj, {ki, 0, 3}, {kj, 0, 3}] 
(* -> {{0, 0, 0, 0}, {0, 1, 2, 3}, {0, 2, 4, 6}, {0, 3, 6, 9}} *)

Export["testgrid.h5", {testgrid, ki, kj}, {"Datasets", {"gridtest", "x", "y"}}] 
(* -> "testgrid.h5" *)

Import["testgrid.h5"] (* -> {"/y"} *)

Import["testgrid.h5", "Data"] (* -> {{0., 1., 2., 3.}} *)
share|improve this question
    
Can you give a specific example of the values of the arrays data, x1, and y1? I tried the last example from the HDF5 documentation in Mathematica 9 and it seemed to work correctly exporting two matrices: Export["test.h5", {{{1, 2}, {2, 3}}, {{10, 11}, {12, 13}}}, {"Datasets", {"m1", "m2"}}] –  Andrew Moylan Jun 14 '13 at 14:51
    
I tried this example in Mathematica 7 also, and it didn't work. Here's another example: In[13]:= ki = N[Table[i, {i, 0, 3}]] kj = N[Table[j, {j, 0, 3}]] testgrid = Table[ki*kj, {ki, 0, 3}, {kj, 0, 3}] Out[13]= {0., 1., 2., 3.} Out[14]= {0., 1., 2., 3.} Out[15]= {{0, 0, 0, 0}, {0, 1, 2, 3}, {0, 2, 4, 6}, {0, 3, 6, 9}} In[16]:= Export["testgrid.h5", {testgrid, ki, kj}, {"Datasets", {"gridtest", "x", "y"}}] Out[16]= "testgrid.h5" In[19]:= Import["testgrid.h5"] Out[19]= {"/y"} In[20]:= Import["testgrid.h5", "Data"] Out[20]= {{0., 1., 2., 3.}} –  Angela Jun 14 '13 at 19:23
1  
seems to be a bug in the export of version 7 only. It works for me with 6.0.2,8.0.4,9.0.1 on windows but not with 7.0.1. Import/Export seems to be done using an external executable connected with MathLink. Maybe one could try to exchange just that in version 7... –  Albert Retey Jun 15 '13 at 12:50
    
@Mr.Wizard are we removing (or no longer adding) version tags now for bugs that affect only a single version? I understand it is not useful for bugs that persist over several versions, but it could still be helpful for these version-specific bugs, just as a platform tag is useful for platform-specific bugs (and do we still add/keep those, or not?). I don't have strong preferences for either practice, but I just wonder about the pros and cons of each approach. –  Oleksandr R. Jul 30 at 13:54
    
@Oleksandr By my interpretation of this accepted proposal we should not be applying any version tags to bugs questions. For the sake of consistency I think this is best. If you have a different perspective please post it in that Meta Q&A. –  Mr.Wizard Jul 30 at 15:54

1 Answer 1

As Albert Retey notes in a comment, this seems to be a bug specific to version 7 (or perhaps just 7.0.1), given that this behavior is not observed in versions 6.0.2, 8.0.4, 9.0.1 or 10.0.2.

Incidentally, you are absolutely right that the file is not exported correctly. If you use a different version to create it as it should be, version 7 will then be able to import it.

share|improve this answer

Your Answer

 
discard

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.