How to open a mat file in python
<p>I was trying to open a mat file in python but my attempts did fail.
Here is my code</p>

<pre><code>from  scipy import *
from  pylab import *


save('rfdata.mat')
import scipy.io as sio
mat = scipy.io.loadmat('rfdata.mat');
</code></pre>

<p>python says that : </p>

<pre><code>Traceback (most recent call last):
  File "C:\Users\Ali\.spyder2-py3\template.py", line 14, in &lt;module&gt;
    mat = scipy.io.loadmat('rfdata.mat');
NameError: name 'scipy' is not defined
</code></pre>

<p>EDIT: I removed all code above and wrote  </p>

<pre><code>import scipy.io as sio
mat = sio.io.loadmat('rfdata.mat');
</code></pre>

<p>still does not work</p>

<p>I appreciate your help</p>

<p>Thanks</p>

<p>As you did:</p>

<pre><code>import scipy.io as sio
</code></pre>

<p>You loaded <code>scipy.io</code> into <code>sio</code>. So, when you call:</p>

<pre><code>mat = scipy.io.loadmat('rfdata.mat');
</code></pre>

<p><code>scipy</code> is not defined, but <code>sio</code> is:</p>

<pre><code>mat = sio.loadmat('rfdata.mat')
</code></pre>

<p>Moreover:</p>

<ul>
<li>try to place all imports at the begining of the file;</li>
<li>do not use <code>;</code> at the end of a line, it is not needed in Python.</li>
</ul>

python