problem loading matlab data with ompc and python

Tim Williams tjandacw at cox.net
Thu May 24 08:06:41 EDT 2012


On May 23, 5:10 pm, no1 <no1.w... at gmail.com> wrote:
> Hi, we're investigating transitioning our company from matlab to python. We found OMPC as a MATLAB m-file-to Python translator, but we're encountering a problem using the translated code to import MATLAB data structures into Python. For example, when we save data within MATLAB this way:
>
> x.a = 5;
> x.b = 6;
> save -v6 test x
>
> this saves data in test.mat, with MATLAB version 6 compatibility (OMPC says it's not compatible with the latest versions of MATLAB). The code to read in data in MATLAB is just
>
> load test
>
> and when we run it through OMPC we get
>
> load(mstring('test.mat'))
>
> but when we run it we get the error message
>
> File "ompclib\ompclib_numpy.py", line 1496, in load
> KeyError: "[('a', '|O4'), ('b', '|O4')]"
>
> Reading in simpler data (up to arrays) does not have this problem.
>
> To get other people in the company to transition, we were hoping that the translation process could be done in one step or on the fly. We could read in MATLAB data using I/O functions imported from scipy, but then the transition isn't seamless any more.
>
> Is there a simple fix to using OMPC? Or a similar alternative that would work better?
>
> Thanks

Have you tried using loadmat from the scipy.io module?

http://docs.scipy.org/doc/scipy/reference/io.html



More information about the Python-list mailing list