support for structs in matlab files
@@ -69,9 +69,20 @@ class MatlabHelper:
return d[keys.popleft()]
else:
return _drill(d[keys.popleft()], keys)
+ def _h52dict(h5group):
+ dout = {}
+ for fieldname in h5group:
+ if isinstance(h5group[fieldname], h5py.Group):
+ dout[fieldname] = _h52dict(h5group)
+ else:
+ dout[fieldname] = h5group[fieldname][()]
+ return dout
if self._old_style_mat:
return _drill(self._data, deque(fieldname.split("/")))
+ else:
+ if isinstance(self._data[fieldname], h5py.Group):
+ return _h52dict(self._data[fieldname])
else:
return self._data[fieldname][()]
