I have a .gz file that I'm trying to open and parse to be put into a database. Running the code below...
def process_file(filename):
with gzip.GzipFile(filename, 'rU', 9) as uncompressed_file:
uncompressed_file.next() # Skip the headers
for line in uncompressed_file:
line = line.replace('\n', '').split('\t')
# Do some more stuff with the line
Generates this error...
File "path/to/script", line 169, in process_file
uncompressed_file.next() # Skip the headers
File "/usr/lib/python2.7/gzip.py", line 450, in readline
c = self.read(readsize)
File "/usr/lib/python2.7/gzip.py", line 256, in read
self._read(readsize)
File "/usr/lib/python2.7/gzip.py", line 307, in _read
uncompress = self.decompress.decompress(buf)
error: Error -3 while decompressing: invalid distance too far back
What's particularly strange is that the code works perfectly on my local machine (Mac OSX 10.9.4), but not on my server (Ubuntu 12.04.4 LTS).
Any insight is appreciated as I'm currently out of ideas.