2021-06-22 20:25:27 +02:00
|
|
|
#!/usr/bin/python3
|
2021-06-10 20:58:48 +02:00
|
|
|
|
2021-06-11 00:01:04 +02:00
|
|
|
import os, gzip
|
2021-06-26 09:33:37 +02:00
|
|
|
# https://stackoverflow.com/questions/8156707/gzip-a-file-in-python
|
2021-06-10 20:58:48 +02:00
|
|
|
|
2021-06-26 09:33:37 +02:00
|
|
|
src_dir='data'
|
|
|
|
out_dir='data_gz'
|
2021-06-10 20:58:48 +02:00
|
|
|
|
2021-06-26 09:33:37 +02:00
|
|
|
if not 'data_gz' in os.listdir():
|
|
|
|
os.mkdir('data_gz')
|
2021-06-10 20:58:48 +02:00
|
|
|
|
2021-06-26 09:33:37 +02:00
|
|
|
for f in os.listdir(src_dir):
|
|
|
|
with open(f'{src_dir}/{f}', 'rb') as f_in:
|
|
|
|
with gzip.open(f'{out_dir}/{f}.gz', 'wb') as f_out:
|
|
|
|
f_out.writelines(f_in)
|