name: excel-scout description: | Pre-operation reconnaissance — read-only scan of Excel files to locate columns relevant to user needs, output a structured scout report for user confirmation. Makes no modifications. When users describe complex Excel operation needs but haven't specified column numbers/names/current values, use this skill first to understand "what's in the file and which columns need to be operated on." 操作前勘察——只讀掃描 Excel 檔案,定位使用者需求涉及的列,輸出結構化勘察報告供使用者確認。不做任何修改。當用戶提出複雜 Excel 操作需求但未明確指定列號/列名/當前值時,先呼叫此技能搞清楚"檔案裡有什麼、哪些列要被操作"。 Trigger keywords: "scout" "explore" "take a look" "check the file" "what columns" "find date columns" "inspect" "survey" 觸發詞包括"先看看""勘察一下""確認一下列""看看檔案結構""有哪些日期列""查一下""scout""探索""瞭解檔案"。
This skill is read-only, no side effects. Uses openpyxl read_only + pandas sampling for fast scanning. It is the prerequisite step for all other operation skills. 本技能只讀不寫,安全無副作用。用 openpyxl read_only + pandas 取樣快速掃描,是其他所有操作技能的前置步驟。
This skill solves a high-frequency pain point: users describe needs in business language ("convert dates to yyyymmdd", "change country codes to Chinese names"), but don't know which column corresponds to what or what the current values are. Figure out the target columns before operating, to avoid modifying wrong columns.
本技能解決一個高頻痛點:使用者描述需求時用的是業務語言("把日期轉成 yyyymmdd""國別程式碼改中文"),但不知道檔案裡哪一列對應、當前值是什麼。 在動手前先搞清楚目標列,避免改錯列。
User Request (business language) / 使用者需求(業務語言)
│
▼
excel-scout: Scan file → Locate target columns → Show current values → Confirm operation scope
掃描檔案 → 定位目標列 → 展示當前值 → 確認操作範圍
│
▼
Other skills: Execute operations on confirmed target columns / 其他技能: 在已確認的目標列上執行操作
Extract the following from user requirements: / 從使用者需求中提取以下資訊:
| To Extract / 要提取的 | User Says / 使用者說 | Example / 示例 |
|---|---|---|
| File Path / 檔案路徑 | "test-files/xxx.xlsx" / "測試檔案/xxx.xlsx" | Must be explicit / 必須明確 |
| Operation Intent / 操作意圖 | "dates to text" / "country codes to Chinese" / "renumber" / "日期轉文本""國別改中文""序號重排" | One target column per intent / 每項一個目標列 |
| Column Characteristics / 操作列特徵 | Column name keywords / data type / position / 列名關鍵字 / 資料型別 / 位置 | Infer / 推斷 |
import os, sys
from openpyxl import load_workbook
from openpyxl.utils import get_column_letter
from datetime import datetime
import pandas as pd
FILE = 'target.xlsx' / FILE = '目標檔案.xlsx'
size_mb = os.path.getsize(FILE) / 1024 / 1024
# ====== A. Read headers (fast with read_only) / 讀表頭 ======
wb = load_workbook(FILE, read_only=True)
ws = wb.active
headers = {}
for cell in ws[1]:
if cell.value:
headers[cell.column] = str(cell.value).strip()
total_cols = len(headers)
print(f'File: {os.path.basename(FILE)} ({size_mb:.0f}MB) / 檔案: {os.path.basename(FILE)} ({size_mb:.0f}MB)')
print(f'Columns: {total_cols} / 列數: {total_cols}')
# Print full header inventory / 列印完整表頭清單
print(f'\n=== Header Inventory / 表頭清單 ===')
for col_idx in sorted(headers.keys()):
cl = get_column_letter(col_idx)
print(f' {cl}({col_idx}): {headers[col_idx]}')
wb.close()
# ====== B. data_only sample scan for date columns / data_only 取樣掃描日期列 ======
wb2 = load_workbook(FILE, read_only=True, data_only=True)
ws2 = wb2.active
date_cols = {}
for row in ws2.iter_rows(min_row=2, max_row=min(500, ws2.max_row or 999999)):
for cell in row:
if isinstance(cell.value, datetime) and cell.column not in date_cols:
date_cols[cell.column] = headers.get(cell.column, '?')
wb2.close()
if date_cols:
print(f'\nFound {len(date_cols)} date columns / 發現 {len(date_cols)} 個日期列:')
for c in sorted(date_cols):
print(f' {get_column_letter(c)}({c}): {date_cols[c]}')
# ====== C. pandas sample read (first N rows only) / pandas 取樣讀資料 ======
df_sample = pd.read_excel(FILE, nrows=5000)
print(f'\nTotal rows (sample cap): {len(df_sample)} / 總行數(取樣上限): {len(df_sample)}')
# ====== D. Locate target columns per user requirements / 針對使用者需求定位目標列 ======
# For each operation intent, match target columns and display current values
# 對每一項操作意圖,匹配目標列並展示當前值
for intent in ['Dates→yyyymmdd / 日期→yyyymmdd', 'Country codes→Chinese / 國別程式碼→中文', 'Renumber / 序號重排']:
# Match by keyword or data type / 按關鍵字或資料型別匹配
# Show target column + current value samples / 展示目標列 + 當前值樣本
pass
Format as follows / 格式如下:
═══════════════════════════════════════════════
Scout Report / 勘察報告: ultimate-merge.xlsx / 終極合併.xlsx
═══════════════════════════════════════════════
File: 195MB | 47 cols | ~330K rows / 檔案: 195MB | 47列 | 約33萬行
=== Header Inventory / 表頭清單 ===
A(1): Seq / 序號
B(2): Title (Chinese) / 標題 (中文)
C(3): Abstract (Chinese) / 摘要 (中文)
...all listed / 全部列出...
=== Date Columns (datetime type) / 日期列 (datetime 型別) ===
G(7): Publication Date / 公開(公告)日
J(10): Application Date / 申請日
AB(28): Estimated Expiry / 預估到期日
AD(30): Grant Date / 授權公告日
AP(42): First Publication Date / 首次公開日
(5 date columns total / 共5個日期列)
=== Located by Requirements / 按需求定位 ===
Req 1: "Dates in-place→yyyymmdd" / 需求1: "日期原地→yyyymmdd"
Target cols: G(7), J(10), AB(28), AD(30), AP(42)
Current type: datetime
Samples: G→2026-04-24, J→2025-12-30, AB→2045-12-30
Req 2: "Country code→Chinese name" / 需求2: "公開國別程式碼→中文"
Target col: M(13) Publication Country / 公開國別
Current unique values: CN(majority/多數), JP(minority/少數)
Mapping direction: CN→China/中國, JP→Japan/日本
Req 3: "Re-sequence 1→N" / 需求3: "序號重排1→N"
Target col: A(1) Seq / 序號
Current state: Multi-segment concatenation / 多段拼接
Conclusion: Need continuous numbering from scratch / 需要從頭連續編號
═══════════════════════════════════════════════
Is the above correct? Please confirm before execution.
以上是否正確?請確認後開始執行。
After user confirms, pass the confirmed results to subsequent operation skills. / 使用者確認後,將確認結果傳遞給後續操作技能。
來源於7w4.net。
質量良好,實用性強。這個技能幫助使用者在操作 Excel 前先了解檔案結構、找到目標列,避免改錯資料。文件清晰易懂,雙語支援友好,操作步驟明確。不過作為純文件型 Skill,沒有實際可執行的程式碼檔案,開發者使用前需要自行編寫實現程式碼。建議補充完整的程式碼示例以提升可用性。