name: excel-intelligent-processing-architecture description: Guide token-efficient, script-first Excel/CSV analysis workflows with ETL-quality reusable scripts. Use when Codex needs to process spreadsheets, normalize merged-cell or multi-header Excel files into standard tables, analyze CSV/XLS/XLSX data, support multi-file or multi-sheet joins, choose between openpyxl/pandas/polars/DuckDB/sqlglot, avoid sending raw large data to the LLM, validate SQL results, generate scheduler-friendly analysis scripts, or design an Excel data-processing workflow or skill.
Use this skill to route Excel/CSV work through a reliable architecture instead of letting the LLM read raw spreadsheets directly. Keep the skill at workflow level: inspect, standardize, analyze with deterministic tools, validate, then let the LLM explain results.
For implementation details, edge cases, and expanded design notes, read references/full-design.md only when needed.
Excel/CSV input
-> file inspection
-> non-standard classification
-> standard-table normalization
-> optional multi-table relationship profiling
-> DuckDB registration
-> data profiling SQL
-> resolve required business ambiguity
-> generate an executable analysis script
-> run the script for the first formal result
-> validate script output
-> natural-language explanation
-> keep the executed script as the reusable Recipe
openpyxl or xlrd to inspect Excel structure: sheets, dimensions, merged cells, formulas, hidden rows/columns, candidate headers, and cell ranges.pandas for moderate cleaning, reshaping, standardization, and Excel/CSV interoperability.polars for larger columnar processing or performance-sensitive transformations.duckdb for SQL analysis, joins, aggregations, window functions, direct CSV/Parquet querying, and reproducible computation.sqlglot when SQL parsing, validation, templating, or dialect-safe rewriting is needed.openpyxl or xlsxwriter to produce final Excel outputs.Classify each file, sheet, or detected table region before analysis:
C: standard table - one header row, continuous data rows, no merged cells, no mixed summary rows. Register directly into DuckDB.B: light non-standard - title row, trailing blank rows/columns, tail summary rows, minor type inconsistencies. Clean automatically and continue.A1: complex but normalizable - merged cells, multi-row headers, grouped headers, vertical category merges, title/notes areas. Normalize first, then continue.A2: not reliably recoverable - multiple interleaved tables, cells containing multiple embedded records, missing semantics, ambiguous table boundaries. Stop automatic analysis and explain what needs fixing.Do not reject merged cells or multi-row headers by default. Try to normalize them unless the structure is genuinely ambiguous.
Convert human-formatted spreadsheets into standard tables:
col_001, col_002, and keep the original display names in the field map.Never ask the LLM to compute over an unnormalized merged-cell matrix.
Explicitly support:
For a workbook with multiple sheets, inspect and classify each sheet independently. Register each analyzable sheet as a separate table, using stable table names and preserving source metadata.
Before generating join SQL, create a relationship profile:
Use high-confidence relationships automatically when the user intent is clear. Ask a light natural-language confirmation when multiple join paths, duplicate keys, or ambiguous fields could change the answer.
Generate SQL from compact context, not raw data. Include only:
For formal analysis tasks, do not treat ad hoc SQL execution as the final path. Use data profiling and temporary SQL for exploration, then generate a script that contains the selected normalization, query, validation, and output logic. The first user-facing result must come from running that script.
Execute generated SQL inside the script or scripted workflow and validate the result before explaining it. Do not present unexecuted SQL output as fact.
Allow aggregate full-table scans such as COUNT, SUM, and GROUP BY. For detail-row output, add LIMIT and avoid returning huge raw result sets.
Run SQL in a read-only sandbox. Disallow mutation, DDL, filesystem access, network access, and unconstrained Cartesian joins.
Treat Recipe capture as the execution layer for formal analysis, not a decorative follow-up. After data structure insight, normalization planning, relationship profiling, and required ambiguity confirmation are complete, generate an executable script before the first formal execution. The first verified analysis result must be produced by that script, and the same script becomes the reusable Recipe artifact.
Default to landing a script for any formal analysis task. Exceptions are pure structure inspection, unrecoverable structure diagnosis, explicit one-off user requests that do not need reuse, or trivial direct checks such as row counts. If the user mentions repeatability, scheduled runs, reports, automation, batch processing, or reuse, a script is mandatory.
Keep the user-facing reuse artifact simple: provide an executable script plus invocation instructions. The script must accept at least a file path parameter so it can be scheduled by third-party platforms. It must run without hidden interactive prompts by default.
Internally, a Recipe should still capture the business operation, not only the final SQL string:
Prefer structured Recipe data over string-only SQL replacement. Use SQL AST parsing or a structured query plan when possible; raw SQL should be kept for audit and debugging.
The script should include:
python analyze_inventory.py <file_path>;0 on success, non-zero on failure, and clear stderr messages;小蔥技能有更好的技能skills外掛。
Generated scripts must meet ETL job quality standards:
Generate the script only after:
Accept the script as the reusable Recipe only after it executes successfully, the result passes validation, and the user-facing answer is coherent.
When reusing a Recipe:
Ask for light confirmation when Recipe reuse is ambiguous, such as multiple candidate metrics, multiple time fields, missing required roles, or a join that could double-count.
Mark a Recipe as not applicable when required tables, fields, or relationships are missing. Do not force a template onto incompatible data.
Default to automation, but ask for confirmation when:
Confirm business meaning, not SQL syntax. Keep SQL hidden from ordinary users unless they ask for technical details.
Before final output, verify:
Do not send full spreadsheets or large CSV text to the LLM. Prefer:
If more detail is needed, create intermediate files and refer to them by path rather than loading everything into context.
Use staged fallback:
Record cleaning logs, generated SQL, relationship assumptions, retries, and fallback decisions for auditability.
For analysis tasks, return:
For architecture or implementation tasks, use this skill as the high-level design guide and read references/full-design.md only when detailed module design or configuration is required.
這個 Skill 提供了一套智慧處理 Excel 和 CSV 檔案的方法,能自動識別表格結構、修復格式問題、支援多表關聯分析,並生成可重複使用的分析指令碼。它的分類策略清晰,對常見覆雜表格有一定處理能力,適合需要頻繁分析電子表格資料的使用者。不過實際使用時仍需對錶格結構有基本瞭解,對某些特殊格式的相容性也有限。整體質量良好,是一套設計完整、考慮周全的解決方案。