I am trying to read a HDF5-format MATLAB file in python, using the h5py library. This file is called "Q_visSDF_accurate.mat" and has two keys: "filename" and "sdf". "filename contains a cell array strings. "sdf" is a [6001, 49380] matrix containing floats. I had no problem to extract the variable sdf using the following code:
import h5py
data = h5py.File("Q_visSDF_accurate.mat", 'r')
sdf = data.get("sdf")[:,:]
sdf = sdf.astype(float)
However, I cant read the filename variable. I tried:
filename = data.get("filename")[0]
but the code returns:
array([<HDF5 object reference>, <HDF5 object reference>,
<HDF5 object reference>, ..., <HDF5 object reference>,
<HDF5 object reference>, <HDF5 object reference>], dtype=object)
I can I de-reference the containt of the filename variable? Using the hdf5storage package is not a solution, as it works only for python 32 bits and can only read a subset of matlab variables.
hdf5storage? It can read hdf5-based .mat files into a more usable form.