Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

problem loading matlab data with ompc and python

24 views
Skip to first unread message

no1

unread,
May 23, 2012, 5:10:19 PM5/23/12
to
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

Tim Williams

unread,
May 24, 2012, 8:06:41 AM5/24/12
to
Have you tried using loadmat from the scipy.io module?

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

no1

unread,
May 24, 2012, 3:47:18 PM5/24/12
to
Yes (I mentioned the scipi I/O module near the end of my original post) but we were hoping not to have to require the users to learn any Python to start. The simpler the process, the less resistance to using the "new" Python methodology; we were hoping the use of a single "black box" like translator (OMPC) would be enough. We'd really like to avoid any additional steps for the user, like rewriting code, otherwise the users are going to resist the transition.
0 new messages