Share Knowledge
Share Knowledge

Reputation: 11

How to read a .mat file table of contents?

I have a Matlab .mat file for table of contents and I want to extract it using Python.

I am using scipy.io.loadmat but the data is not being extracted. It shows None and matlabopaqe,mcos.

I have uploaded the .mat file here.

import scipy.io 
from scipy.io import loadmat
import numpy 

matdata = scipy.io.loadmat('matfile.mat')

print(matdata.keys())
print(matdata.items())

Upvotes: 1

Views: 784

Answers (1)

Konark K
Konark K

Reputation: 147

Your matfle.mat is properly readable via this code. Can't reproduce the problem here. Below is the data that got displayed on console

dict_keys(['__header__', '__version__', '__globals__', 'None', 
'__function_workspace__'])
dict_items([('__header__', b'MATLAB 5.0 MAT-file, Platform: PCWIN64, Created on: 
Fri Feb 25 11:47:02 2022'), ('__version__', '1.0'), ('__globals__', []), ('None', MatlabOpaque([(b'patients', b'MCOS', b'table', array([[3707764736],
   [         2],
   [         1],
   [         1],
   [         1],
   [         2]], dtype=uint32))],
         dtype=[('s0', 'O'), ('s1', 'O'), ('s2', 'O'), ('arr', 'O')])), 
('__function_workspace__', array([[ 0,  1, 73, ...,  0,  0,  0]], dtype=uint8))])

Upvotes: 0

Related Questions