Read .tar.gz file in Python
<p>I have a text file of 25GB. so i compressed it to tar.gz and it became 450 MB. now i want to read that file from python and process the text data.for this i referred <a href="https://stackoverflow.com/questions/2018512/reading-tar-file-contents-without-untarring-it-in-python-script">question</a> . but in my case code doesn't work. the code is as follows : </p>

<pre><code>import tarfile
import numpy as np 

tar = tarfile.open("filename.tar.gz", "r:gz")
for member in tar.getmembers():
     f=tar.extractfile(member)
     content = f.read()
     Data = np.loadtxt(content)
</code></pre>

<p>the error is as follows : </p>

<pre><code>Traceback (most recent call last):
  File "dataExtPlot.py", line 21, in &lt;module&gt;
    content = f.read()
AttributeError: 'NoneType' object has no attribute 'read'
</code></pre>

<p>also, Is there any other method to do this task ?</p>