-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcompress.py
More file actions
33 lines (25 loc) · 928 Bytes
/
compress.py
File metadata and controls
33 lines (25 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
from loguru import logger
from sc_compression import compress
from xcoder.localization import locale
def compress_csv():
from sc_compression.signatures import Signatures
folder = "./CSV/In-Decompressed"
folder_export = "./CSV/Out-Compressed"
for file in os.listdir(folder):
if file.endswith(".csv"):
try:
with open(f"{folder}/{file}", "rb") as f:
file_data = f.read()
with open(f"{folder_export}/{file}", "wb") as f:
f.write(compress(file_data, Signatures.LZMA))
except Exception as exception:
logger.exception(
locale.error
% (
exception.__class__.__module__,
exception.__class__.__name__,
exception,
)
)
print()