Reputation: 129
I was trying to open a mat file in python but my attempts did fail. Here is my code
from scipy import *
from pylab import *
save('rfdata.mat')
import scipy.io as sio
mat = scipy.io.loadmat('rfdata.mat');
python says that :
Traceback (most recent call last):
File "C:\Users\Ali\.spyder2-py3\template.py", line 14, in <module>
mat = scipy.io.loadmat('rfdata.mat');
NameError: name 'scipy' is not defined
EDIT: I removed all code above and wrote
import scipy.io as sio
mat = sio.io.loadmat('rfdata.mat');
still does not work
I appreciate your help
Thanks
Upvotes: 2
Views: 6452
Reputation: 7150
As you did:
import scipy.io as sio
You loaded scipy.io
into sio
. So, when you call:
mat = scipy.io.loadmat('rfdata.mat');
scipy
is not defined, but sio
is:
mat = sio.loadmat('rfdata.mat')
Moreover:
;
at the end of a line, it is not needed in Python.Upvotes: 4