loadmat doesn't work on String arrays
See original GitHub issueDescribe the solution you’d like
I am trying to load a mat file with an array of strings in it. I have read the documentation and loadmat should work on v6 files, and v7-v7.2. I have tried saving the mat file from matlab as all of these formats and I have the same issue with each. The mat file loads with the numerical data, but not the string data. I’ve tried to search through the issues and I see that there are issues with implementing classdef’s in matlab as well as similar issues to mine come up with the file being loaded with a key ‘None’ the has a MatlabOpaque object.
Describe alternatives you’ve considered I’ve tried saving the string array as a separate array and this produces the same result. I have also tried all of the ideas in This stackoverflow question, and none of them allow me to load the strings. The h5py loads it in the same way.
At this point I cannot figure out how to load these strings in using any method.
from scipy.io import loadmat scipy.__version__
1.4.1
mat_file = loadmat('data.mat',mat_dtype=True)
mat_file
{'__header__': b'MATLAB 5.0 MAT-file, Platform: GLNXA64, Created on: Tue Apr 7 15:07:44 2020',
'__version__': '1.0',
'__globals__': [],
'None': MatlabOpaque([(b'time', b'MCOS', b'string', array([[3707764736],
[ 2],
[ 1],
[ 1],
[ 3],
[ 1]], dtype=uint32))],
dtype=[('s0', 'O'), ('s1', 'O'), ('s2', 'O'), ('arr', 'O')]),
'__function_workspace__': array([[ 0, 1, 73, ..., 0, 0, 0]], dtype=uint8)}```
I have also tried setting all the relevant kwargs in the loadmat function with no different results.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7 (1 by maintainers)
Same here
Still facing this issue.