Colab_解壓縮

Colab_解壓縮
Photo by SumUp / Unsplash
from google.colab import drive
import zipfile
import os

# 掛載 Google Drive
drive.mount('/content/drive')

# 設定壓縮檔的完整路徑
zip_file_path = "/content/drive/My Drive/artsy_2024_12_Data/xxxxxx0305H.zip"

# 設定解壓縮的目標資料夾
extract_folder = "/content/drive/My Drive/artsy_2024_12_Data/extracted_files"

# 確保目標資料夾存在
os.makedirs(extract_folder, exist_ok=True)

# 解壓縮 zip 檔案
with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:
    zip_ref.extractall(extract_folder)

print(f"✅ 解壓縮完成,文件存放於: {extract_folder}")

# 顯示解壓縮後的文件
print("📂 解壓後的文件列表:")
for file_name in os.listdir(extract_folder):
    print(f"- {file_name}")