I need to figure out how to write file output to a compressed file in Python, similar to the two-liner below:
open ZIPPED, \"| gzip -c > zipped.gz\"; print ZI
Try something like this:
from subprocess import Popen, PIPE f = open('zipped.gz', 'w') pipe = Popen('gzip', stdin=PIPE, stdout=f) pipe.communicate('Hello world\n') f.close()