Reading a Matlab's cell array saved as a v7.3 .mat file with h5py

694 views
Skip to first unread message

Servant Mathieu

unread,
Dec 21, 2016, 11:28:15 AM12/21/16
to h5py

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 of 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)

How can I de-reference the content of the filename variable?

Reply all
Reply to author
Forward
0 new messages