File size: 696 Bytes
6f9c387
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import os
import zipfile

# Path to your folder containing CSV files
folder_path = r"C:\Users\David\Documents\DISK E\BI REPORTING\FLOYD REPORT\2025\CAPACITY\DECEMBRE\20151214"

# Loop through all files in the folder
for filename in os.listdir(folder_path):
    if filename.endswith(".csv"):
        csv_path = os.path.join(folder_path, filename)

        # Create a .zip file with the same name
        zip_filename = os.path.splitext(filename)[0] + ".zip"
        zip_path = os.path.join(folder_path, zip_filename)

        with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zipf:
            zipf.write(csv_path, arcname=filename)

        print(f"Zipped: {csv_path}{zip_path}")