title: How to read from a text file compressed with 7z?
body: <p>I would like to read (in Python 2.7), line by line, from a csv (text) file, which is 7z compressed. I don't want to decompress the entire (large) file, but to stream the lines.</p>
  
  <p>I tried <code>pylzma.decompressobj()</code> unsuccessfully. I get a data error. Note that this code doesn't yet read line by line:</p>
  
  <pre><code>input_filename = r"testing.csv.7z"
  with open(input_filename, 'rb') as infile:
      obj = pylzma.decompressobj()
      o = open('decompressed.raw', 'wb')
      obj = pylzma.decompressobj()
      while True:
          tmp = infile.read(1)
          if not tmp: break
          o.write(obj.decompress(tmp))
      o.close()
  </code></pre>
  
  <p>Output:</p>
  
  <pre class="lang-none prettyprint-override"><code>    o.write(obj.decompress(tmp))
  ValueError: data error during decompression
  </code></pre>