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

Dharhas Pothina Dharhas.Pothina@twdb.state.tx...
Tue Oct 12 08:12:23 CDT 2010


Mathew,

Many thanks. I'll test this out as soon as I can. I think for now I will go with the MatFile5Reader approach and just load the variables I need, since from what I understand this approach will work with the current version of scipy. I need to deploy this script across several users and I prefer to install release versions of Scipy on their machines. I'll transition to loadmat once that makes it into the stable release.

Will these fixes make it into the next release of scipy?

- dharhas

>>> Matthew Brett <matthew.brett@gmail.com> 10/12/2010 1:51 AM >>>
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
_______________________________________________
SciPy-User mailing list
SciPy-User@scipy.org 
http://mail.scipy.org/mailman/listinfo/scipy-user



More information about the SciPy-User mailing list