- #!/usr/bin/python3
-
- import os, gzip
- # https://stackoverflow.com/questions/8156707/gzip-a-file-in-python
-
- src_dir='data'
- out_dir='data_gz'
-
- if not 'data_gz' in os.listdir():
- os.mkdir('data_gz')
-
- 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)
|