I have a file that consists of compressed content plus a 32 byte header. The header contains info such as timestamp, compressed size, and uncompressed size.
The file itself is about 490mb and the header indicates the uncompressed size is close to 2.7gb (it's clearly incorrect, as it also believes the compressed size to be 752mb).
I've stripped the header and generated the compressed payload and can uncompress it with zlib.
The problem is that it is only decompressing 19kb, which is much smaller than 490mb (the bare minimum it should be, but I'm expecting around 700mb uncompressed).
My code is below:
import zlib
def consume (inputFile):
content = inputFile.read()
print "Attempting to process " + str(len(content)) + " bytes..."
outfile = open('output.xml', 'w')
inputFile = zlib.decompress(content)
print "Attempting to write " + str(len(inputFile)) + " bytes..."
outfile.write(inputFile)
outfile.close()
infile = open('payload', 'rb')
consume(infile)
infile.close()
When ran, the program outputs:
Attempting to process 489987232 bytes... Attempting to write 18602 bytes...
I've tried to use zlib.decompressionobj()
, though this generates an incorrect header warning. zlib.decompress()
works fine and produces the decompressed XML that I expect...just far too little of it.
Any pointers or suggestions are greatly appreciated!