Row and column headers on datasets

I want to have row and column headers on an HDF5 dataset of double that shows up like this in the viewer:

            Col #1  Col #2  Col #3

Row # 1 90.1 50.2 42.3
Row # 2 22.3 44.2 55.4
Row #3 80.3 60.4 70.4

Could someone point me to sample code or where in the documentation it explains how to do this?

Thank you

Hi @gmbe,

To achieve a dataset with columns and rows the way it is described, you need to play with compound data types.

In HDFql, a high-level (declarative) language to manage HDF5 files, this can easily be achieved as follows in C (in addition to C, HDFql supports C++, C#, Java, Python, R and Fortran):

// create an HDF5 file named 'test.h5' and use (i.e. open) it
hdfql_execute("CREATE AND USE FILE test.h5");

// create a compound dataset named 'dset' with three members ('col_1', 'col_2' and 'col_3') of type double with five rows
hdfql_execute("CREATE DATASET dset AS COMPOUND(col_1 AS DOUBLE, col_2 AS DOUBLE, col_3 AS DOUBLE)(5)");

Hope it helps!

When you say “the viewer,” do you mean HDFView?

If so, check out

Tools -> User Options -> General Settings -> Data -> Index Base

The default setting is 0-based. Set to 1-based and that should do the trick.


Yes, I meant HDFView. I didn’t see a difference with 1-based but I don’t have any row or column headers. Looking into compound datasets for the row headers. I’m not sure about the column headers

Using the example from Compound datatype with int, float and array of floats - #2 by ajelenak , I get this rendering in HDFView

The h5dump output looks like this:

HDF5 "hdf-forum-8083.h5" {
GROUP "/" {
   GROUP "group1" {
      DATASET "ds1" {
            H5T_STD_I32LE "id";
            H5T_IEEE_F32LE "time";
            H5T_ARRAY { [10][2] H5T_IEEE_F32LE } "matrix";
         DATASPACE  SIMPLE { ( 10 ) / ( 10 ) }

I’m not sure what you mean by “row headers.” There are row indexes, the greyish leftmost column, 1-based.

This is a 1D dataset (array). Each element (cell) of the dataset has three fields (id, time, matrix), but they are fields of the compound datatype, not the dataset. You are welcome to think about this as a table, but it is not a table in the sense of tables in the relational model. As it is set up, HDFView renders ND-arrays as stacks of 2D slices. Aside from the array indices, there are no headers to speak of. One could write a GUI module to change that rendering or modify the HDFView code to change the rendering of 1D compound datasets, but that’s not been done to my knowledge.


@gmbe, are you looking for this capability from HDFView?

Yes. The data will also be loaded by code we have written and they need some way to identify the data

1 Like

Results !


A row header is the label at the start of the row. Here is a dataset of inflation by state and by month. The row header is the month, the column header is the state

     TX   MI   WA  

Jan 9.0 9.1 8.9
Feb 8.1 8.2 8.5
Mar 7.0 7.3 7.1
Apr 5.5 5.6 5.7
May 4.1 4.2 4.3

Thank you