How to Store String type in HDF5


#1

Dear EveryOne:
I changed my h5py from version 2.10.0 to 3.2.1 recently. I found the string dataset output was changed from string type to bytes type. So I should change my codes to fit this situation. There are two ways to do this:
1st. Decode the output bytes
2nd. Save the string in the attribute which supports the string type, and no decode was needed when reading it.
I want to know which way is better and if the attribute will also support the string type in the future.
Thank you in advance.


#3

It is not clear to me what your situation is.

Have you tried asstr() to read HDF strings created by h5py?

From Read HDF5 strings as str with h5py 2.x and 3.0

f = h5py.File('foo.h5', 'r')
ds = f['data']
strings = ds.asstr()[()]

#4

thanks for the awesome information.


#5

Thanks for your reply.