Files
ewoooc/scripts/archive/direct_read_excel.py
ogt 1b4f3a7bbe
Some checks failed
CD Pipeline / deploy (push) Failing after 59s
feat: EwoooC 初始化 — 完整專案推版至 Gitea
- 建立 Gitea Actions CD pipeline (.gitea/workflows/cd.yaml)
- 部署模式: rsync Python 檔案至 188 → docker restart (volume mount)
- Dockerfile/requirements 變動時自動重建 Docker image
- 部署通知: Telegram (開始/成功/失敗)
- 健康檢查: https://mo.wooo.work/health (最多 5 次重試)
- 同步最新 CLAUDE.md / ADR-008 / memory (2026-04-19)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 01:21:13 +08:00

88 lines
2.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
直接讀取 Excel 檔案,查看實際內容
"""
import pandas as pd
import sys
import os
def read_excel_directly():
"""直接讀取 Excel"""
# 尋找 Excel 檔案
possible_paths = [
'/Users/ogt/momo_pro_system/缺貨測試.xlsx',
'/Users/ogt/缺貨測試.xlsx',
'/Users/ogt/Downloads/缺貨測試.xlsx',
]
excel_path = None
for path in possible_paths:
if os.path.exists(path):
excel_path = path
break
if not excel_path:
print("找不到 Excel 檔案,請提供完整路徑")
print("使用方式: python3 direct_read_excel.py <Excel檔案路徑>")
return
print("=" * 80)
print(f"讀取 Excel: {excel_path}")
print("=" * 80)
try:
# 讀取 Excel
df = pd.read_excel(excel_path)
print(f"\n📊 資料概況:")
print(f" 總行數: {len(df)}")
print(f" 總欄位數: {len(df.columns)}")
print(f"\n📋 所有欄位名稱:")
for i, col in enumerate(df.columns, 1):
print(f" {i:2d}. {col}")
print(f"\n📄 第一行完整數據:")
print("=" * 80)
for col in df.columns:
value = df[col].iloc[0]
value_type = type(value).__name__
print(f"{col:20s}: {value} (類型: {value_type})")
print("\n" + "=" * 80)
# 檢查是否有18個欄位
if len(df.columns) == 18:
print("✅ 欄位數量正確18 個")
else:
print(f"⚠️ 欄位數量不對:{len(df.columns)} 個(預期 18 個)")
except Exception as e:
print(f"\n❌ 錯誤: {e}")
import traceback
traceback.print_exc()
if __name__ == '__main__':
if len(sys.argv) > 1:
# 使用提供的路徑
excel_path = sys.argv[1]
if os.path.exists(excel_path):
print("=" * 80)
print(f"讀取 Excel: {excel_path}")
print("=" * 80)
df = pd.read_excel(excel_path)
print(f"\n總行數: {len(df)}, 總欄位數: {len(df.columns)}")
print(f"\n欄位清單:")
for i, col in enumerate(df.columns, 1):
print(f" {i}. {col}")
print(f"\n第一行數據:")
for col in df.columns:
print(f" {col}: {df[col].iloc[0]}")
else:
print(f"檔案不存在: {excel_path}")
else:
read_excel_directly()