Socialify

Folder ..

Viewing zipper.py
13 lines (12 loc) • 414.0 B

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
import zlib
from os.path import exists
from os import remove


filename_in = "arima.pkl"
filename_out = "arima.compressed"
if exists(filename_out):
    remove(filename_out)
with open(filename_in, mode="rb") as fin, open(filename_out, mode="wb") as fout:
    data = fin.read()
    print("Compressing Pickle File...")
    compressed_data = zlib.compress(data, zlib.Z_BEST_COMPRESSION)
    fout.write(compressed_data)