Array [2000] of 8 Bit unsigned integer type Question

Gonna admit up front I have been out of the low level HDF5 API for a bit but I just got handed an HDF5 file that has a data set with a data type of “Array [2000] of 8 Bit unsigned integer type”. Now logically I understand what the data is. What I am unsure of is what C/C++ set of calls do I need to string together to read that data? Is there an example file in the HDF5 source that I could look at? Sorry for the basic questions, I’m just not sure what this is called so I’m not sure how to search for examples.

Thank You

Hi @mike.jackson,

You may want to check out HDFql, a high-level (declarative) programming language that alleviates the user from HDF5 low-level details.

The following code snippet solves the issue you described in C:

// declare variable 'data'
unsigned char data[2000];

// register variable 'data' for subsequent use (by HDFql)
hdfql_variable_register(&data);

// read values from dataset 'dset' and populate variable 'data' with these
hdfql_execute("SELECT FROM dset INTO MEMORY 0");

// print values stored in variable 'data'
for(int i = 0; i < 2000; i++)
{
   printf("%d\n", data[i]);
}

For additional information, please check HDFql reference manual.

Perhaps this example can help: hdf5/HDF5Examples/C/TUTR/h5_rdwt.c at hdf5_1_14_5 · HDFGroup/hdf5 · GitHub

If you can, run h5dump on that dataset so you know exactly which datatype to use in the H5Dread() function.

1 Like

@ajelenak Thank you for the link. They proved very useful.

1 Like