I am trying to transfer data through a subprocess, gzip it and write to a file. The following work. I wonder if you can use your own python gzip library instead.
fid = gzip.open(self.ipFile, 'rb') # input data oFid = open(filtSortFile, 'wb') # output file sort = subprocess.Popen(args="sort | gzip -c ", shell=True, stdin=subprocess.PIPE, stdout=oFid) # set up the pipe processlines(fid, sort.stdin, filtFid) # pump data into the pipe
QUESTION: How do I do this? .. where is the gzip python package used? I'm mostly interested in finding out why the following gives me text files (instead of a compressed binary version) ... very strange.
fid = gzip.open(self.ipFile, 'rb') oFid = gzip.open(filtSortFile, 'wb') sort = subprocess.Popen(args="sort ", shell=True, stdin=subprocess.PIPE, stdout=oFid) processlines(fid, sort.stdin, filtFid)
source share