[SciPy-User] scipy.io.loadmat error when trying to read a .mat file

Matthew Brett matthew.brett at gmail.com
Tue Oct 12 02:51:16 EDT 2010


Hi again,

> You can already specify a variable name (not a regexp), so for example:
>
> from scipy.io.matlab.mio5 import MatFile5Reader
> rdr = MatFile5Reader(open('20100819125947.mat', 'rb'))
> var = rdr.get_variables(['System'])
>
> will already return you the first 'System' variable, that would
> otherwise be overwritten when you read the full set of variables.  You
> are right, that should be in the loadmat API somewhere.

Actually, I just did add that - in the same branch ('mio-read-fix')

In [5]: import scipy.io as sio
In [6]: vars = sio.loadmat('20100819125947.mat', variable_names=['System'])

will return just the first occurrence of a variable named 'System' in the file.

Best,

Matthew



More information about the SciPy-User mailing list