Dec 13, 2011

File

Best way to temporarily unzip a file

gzip.open(zipfile).read()  # will give you the contents of the file in a single string.
with open(tmpfile, "wb") as tmp:
    shutil.copyfileobj(gzip.open(zipfile), tmp)

No comments: