[SciPy-user] reading .mat-files (Matlab 7)

oliver.tomic@matfor... oliver.tomic@matfor...
Wed Jul 25 14:25:36 CDT 2007


Rob and Stefan,

the problem below described by Rob is exactly what I have experienced. I
get the same error. I use scipy 0.5.2 and numpy 1.0.3.

Is there a newer version of scipy than 0.5.2 or do I have to use the svn?

Here is a file that failed to load with scipy.io:
(See attached file: brod.mat)
It was created with Matlab 7.3 with backward compatibility to (-v6).

Cheers
Oliver



scipy-user-bounces@scipy.org wrote on 25.07.2007 17:05:28:

> Stefan,
>
> scipy.io.loadmat from scipy 0.5.2 doesn't work on anything but v4
> files for me. I generated extremely simple mat files (one small matrix
> in 'test.mat') with my matlab 7.3 using the -v6, -v5, and -v4 options,
> and scipy complained with this in all but the -v4 case:
>
> In [1]: import scipy.io as io
>
> In [2]: io.loadmat('test')
>
---------------------------------------------------------------------------
> exceptions.AttributeError                            Traceback (most
> recent call last)
>
> c:\temp\<ipython console>
>
> C:\Python24\lib\site-packages\scipy\io\mio.py in loadmat(file_name,
> mdict, appen
> dmat, basename, **kwargs)
>      94     '''
>      95     MR = mat_reader_factory(file_name, appendmat, **kwargs)
> ---> 96     matfile_dict = MR.get_variables()
>      97     if mdict is not None:
>      98         mdict.update(matfile_dict)
>
> C:\Python24\lib\site-packages\scipy\io\miobase.py in
> get_variables(self, variable_names)
>     267             variable_names = [variable_names]
>     268         self.mat_stream.seek(0)
> --> 269         mdict = self.file_header()
>     270         mdict['__globals__'] = []
>     271         while not self.end_of_stream():
>
> C:\Python24\lib\site-packages\scipy\io\mio5.py in file_header(self)
>     508         hdict = {}
>     509         hdr = self.read_dtype(self.dtypes['file_header'])
> --> 510         hdict['__header__'] = hdr['description'].strip('
\t\n\000')
>     511         v_major = hdr['version'] >> 8
>     512         v_minor = hdr['version'] & 0xFF
>
> AttributeError: 'numpy.ndarray' object has no attribute 'strip'
>
>
> This is with numpy 1.0.2. I wonder if this is the problem that Oliver
has?
>
> -Rob
>
> On 25/07/07, Stefan van der Walt <stefan@sun.ac.za> wrote:
> > Hi Oliver
> >
> > On Wed, Jul 25, 2007 at 01:06:18PM +0200, oliver.tomic@matforsk.no
wrote:
> > > Is there now support in scipy.io (scipy 0.52) for reading .mat-files
from
> > > Matlab 7? I undestand that it supports older versions (v4 and v5).
Are
> > > there any plans to support for Matlab 7 .mat-files?
> >
> > >From the docstring:
> >
> > "v4 (Level 1.0), v6 and v7.1 matfiles are supported."
> >
> > Cheers
> > Stéfan
> > _______________________________________________
> > SciPy-user mailing list
> > SciPy-user@scipy.org
> > http://projects.scipy.org/mailman/listinfo/scipy-user
> >
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
-------------- next part --------------
A non-text attachment was scrubbed...
Name: brod.mat
Type: application/octet-stream
Size: 8656 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-user/attachments/20070725/3a04b33d/attachment.obj 


More information about the SciPy-user mailing list