Hello!
I was wondering if there is a way to write the binary representation of a uint8_t to single cell in a HDF5 data table. Currently, I have a struct with integers (uint8_t) that I am writing to HDF5, but I want those integers to be in binary format. My struggle is writing this binary value to HDF5 file.
I’m trying to avoid using a char array and strings in hopes to reduce space and avoid the unpredictable behavior with different compilers. Integer arrays overly complicate my implementation.
Any help is appreciated. Thanks!
Hello!
If by ‘data table’ you mean an HDF5 Dataset, then it may fit your use case to write uint8_t values to a dataset with the H5T_NATIVE_UINT8
datatype. This should preserve the binary layout used by your local machine.
Since you’re interested in the data as a series of bit values, you might also find the bitfield datatypes useful, but this could require conversion from your representation of the data.
Hope this helps!
Thanks for the response! Yep, I ended up using the uint8 datatype. I did use a char array for a bit so that the binary could be viewed using a H5viewer, but that ended up taking way too much space.
Appreciate it.
1 Like