relb.test 0 Newbie Poster

So here's the problem. I have sample.gz file which is roughly 60KB in size. I want to decompress the first 2000 bytes off this file. I am running into CRC check failed error cuz I guess the gzip CRC field appears at the end of file, and it requires the entire gzipped file to decompress. Is there a way to get around this? I dont care about the CRC check. Even if I fail to decompress cuz of bad CRC, that is OK. Is there a way to get around this and unzip partial .gz files?

The code I have so far is

import gzip
import time
import StringIO

file = open('sample.gz', 'rb')
mybuf = MyBuffer(file)
mybuf = StringIO.StringIO(file.read(2000))
f = gzip.GzipFile(fileobj=mybuf)
data = f.read()
print data

Thanks.