We actually do this exact operation for our project. What I decided to do was to first flatten from a "vector of vectors" into a single array, then write that array as a "normal" array to HDF5. Add an attribute to the HDF5 dataset to state what the array represents so that when you read it back from HDF5 you know that you will need to recreate your own data structure.

Another way that we tackled the issue was to write the data into a contiguous array and then write each of the "length" values into another contiguous array. The write the data to an HDF5 data set and the "Length" array as an attribute array of the value array. I can send a link to this implementation if you want. With your data you would end up with the following arrays:


Value:23 41 54 12 46 29 19 60 93 18 58 29 58 17 50 38 58 95
Length:9 9 5 5 9

There are pros and cons to do it either of these ways.
--
Michael A. Jackson
BlueQuartz Software, LLC
[e]: mike.jack...@bluequartz.net


Steven Walton wrote:
So I'm wondering if there is a good way to write an irregular shaped 2D
array into hdf5. And example of this would be like storing vtk node
connections for an unstructured grid. First number noting the cell type
and the next numbers denoting the nodes.

9 23 41 54 12
9 46 29 19 60
5 93 18 58
5 29 58 17
9 50 38 58 95

So the array has some rows that are length 5 and others that are length
4 (or arbitrary). I understand how to do this with C++ vectors and
push_back, but those don't create contiguous arrays. Is there another
way to create this in a way that HDF would accept?

-Steven

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

_______________________________________________
Hdf-forum is for HDF software users discussion.
Hdf-forum@lists.hdfgroup.org
http://lists.hdfgroup.org/mailman/listinfo/hdf-forum_lists.hdfgroup.org
Twitter: https://twitter.com/hdf5

Reply via email to