Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. Export["test.h5", {{{1, 2}, {2, 3}}, {{10, 11}, {12, 13}}}, {"Datasets", {"m1", "m2"}}]
  2. r = Import["test.h5", "Rules"]
  3. Export["test1.h5", r, "Rules"]
  4.  
  5. Export::errelem: The Export element Dataset1 contains a malformed data structure and could not be exported to HDF5 format. >>
  6. Export::noopen: Cannot open C:UsersajasjaDocumentstest1.h5. >>
  7.  
  8. Export["test.h5",
  9. {{{1,2},{2,3}},{{10,11},{12,13}}},
  10. {"Datasets",{"m1","m2"}},
  11. {"Attributes"->{
  12. "m1"->{
  13. "ScalarValue"->{10.0},
  14. "ArrayValues"->{1.0,2.0,3.0},
  15. "Info"->{""This is a text string""}},
  16. "m2"->{
  17. "ScalarValue"->{20.0},
  18. "ArrayValues"->{-1.0,-2.0,-3.0},
  19. "Info"->{""This is a text string""}}}}]
  20.  
  21. In[] := Import["example.h5", "Attributes"]
  22. Out[] := {{ArrayValues->{1.,2.,3.},Info->{"This is a text string"},ScalarValue->{10.}},{ArrayValues->{-1.,-2.,-3.},Info->{"This is a text string"},ScalarValue->{20.}}}
  23.  
  24. In[1]:= Export["test.h5", "path/to/dataset" -> {
  25. "Data" -> {1, 2, 3, 4},
  26. "Attributes" -> {
  27. "DataDescription" -> "SomeIntegers",
  28. "DataLength" -> 4
  29. }
  30. }
  31. ];
  32. Import["test.h5", {"Attributes", "path/to/dataset"}]
  33.  
  34. Out[2]= <|"DataDescription" -> "SomeIntegers", "DataLength" -> 4|>
  35.  
  36. In[3]:= Export["test.h5", {
  37. "Datasets" ->
  38. "path/to/dataset" -> {1, 2, 3, 4},
  39. "Attributes" ->
  40. "path/to/dataset" -> {
  41. "DataDescription" -> "SomeIntegers",
  42. "DataLength" -> 4
  43. }
  44. },
  45. "Rules"
  46. ];
  47. Import["test.h5", {"Attributes", "path/to/dataset"}]
  48.  
  49. Out[4]= <|"DataDescription" -> "SomeIntegers", "DataLength" -> 4|>
  50.  
  51. In[5]:= Export["test.h5",
  52. "path/to/dataset" -> {
  53. "NewAttribute" -> <|"x" -> 1, "y" -> "z"|>
  54. },
  55. "Attributes",
  56. OverwriteTarget -> "Append"
  57. ];
  58. Import["test.h5", {"Attributes", "path/to/dataset"}]
  59.  
  60. Out[6]= <|"DataDescription" -> "SomeIntegers", "DataLength" -> 4,
  61. "NewAttribute" -> <|"x" -> 1, "y" -> "z"|>|>
  62.  
  63. In[7]:= Export["test.h5",
  64. "path/to/dataset" -> {
  65. "DataDescription" -> "New description of the data."
  66. },
  67. "Attributes",
  68. OverwriteTarget -> "Append",
  69. "AppendMode" -> "Overwrite"
  70. ];
  71. Import["test.h5", {"Attributes", "path/to/dataset"}]
  72.  
  73. Out[8]= <|"DataDescription" -> "New description of the data.", "DataLength" -> 4,
  74. "NewAttribute" -> <|"x" -> 1, "y" -> "z"|>|>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement