Python: how to close mat file?
<p>I'm reading data from 20k mat files into an array.
After reading around 13k files, the process is ended with "Killed" message.
Apparently, it looks like the problem is that too many files are open.
I've tried to find out how to explicitly "close" mat files in Python, but didn't find any except for savemat which is not what I need in this case.</p>

<p>How can I explicitly close mat files in python?</p>

<pre><code>import scipy.io
x=[]
with open('mat_list.txt','r') as f:
    for l in f:
            l=l.replace('\n','')
            mat = scipy.io.loadmat(l)
            x.append(mat['data'])
</code></pre>