python-spreadsheet-debug
它能做什么
这项技能为 AI 智能体提供了一套有序的检查步骤,用于 Python 中的电子表格任务。它适合电子表格脚本失败、需要判断问题出在环境设置还是脚本本身的人。
适用场景
- ✓当电子表格脚本失败,而 shell 输出难以阅读的时候。
- ✓当你怀疑 Python 或某个库缺失,或版本不对的时候。
- ✓当你希望在正式任务前用一次小型测试运行,确认文件可以被读取的时候。
技能链接
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/python-spreadsheet-debug/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的电子表格脚本失败,但原因不明。请检查 Python 和 pandas 是否正常,然后测试读取文件。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会检查它所使用的 Python 及其版本,然后单独导入每个需要的库。接着,它会运行一个简短的测试脚本,读取文件并打印摘要,然后才运行完整任务。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Python Spreadsheet Debugging Workflow
When executing Python scripts for spreadsheet/data processing tasks, use this systematic debugging approach to efficiently isolate environment configuration issues from script logic errors, especially when run_shell returns opaque errors.
Step 1: Verify Python Environment
First, confirm the Python interpreter path and version to ensure you're working in the expected environment:
which python python3
python --version
python3 --version
This identifies whether Python is available and which version is being used.
Step 2: Test Library Imports in Isolation
Before running your full script, verify that required libraries can be imported successfully. Test each critical import individually:
python -c "import pandas; print('pandas:', pandas.__version__)"
python -c "import openpyxl; print('openpyxl:', openpyxl.__version__)"
python -c "import xlrd; print('xlrd:', xlrd.__version__)"
Replace library names based on your script's requirements. This identifies missing dependencies or version conflicts early.
Step 3: Run Minimal Test Script
Create and execute a minimal script that exercises only the core functionality without full business logic:
# test_minimal.py
import pandas as pd
# Test 1: Can we read a file?
try:
df = pd.read_excel('sample.xlsx')
print(f"✓ File read successful: {len(df)} rows")
except Exception as e:
print(f"✗ File read failed: {e}")
# Test 2: Can we perform basic operations?
try:
result = df.groupby('category')['amount'].sum()
print(f"✓ GroupBy operation successful")
except Exception as e:
print(f"✗ Operation failed: {e}")
Run this with: python test_minimal.py
Purpose: This isolates whether the issue is with file access, library functionality, or specific script logic.
Step 4: Execute Full Script
Once the minimal test passes, run the complete script:
python your_script.py
If errors occur now, you know the environment is correctly configured and can focus on debugging the specific logic.
Quick Diagnostic Command
For rapid diagnosis, run all checks in sequence:
echo "=== Python Version ===" && python --version && \
echo "=== Key Imports ===" && python -c "import pandas, openpyxl; print('OK')" && \
echo "=== Ready for full script ==="
Common Issues and Resolutions
| Symptom | Likely Cause | Resolution |
|---|---|---|
ModuleNotFoundError |
Missing package | pip install <package-name> |
ImportError with version |
Version conflict | Check pip list, reinstall specific version |
FileNotFoundError |
Wrong path/context | Verify working directory with pwd |
PermissionError |
File access | Check file permissions or path |
When to Use This Pattern
run_shellreturns cryptic or truncated error messages- Script worked previously but suddenly fails
- Deploying to a new environment or container
- Debugging spreadsheet processing with pandas, openpyxl, xlrd, etc.
Benefits
- Fast isolation: Identifies environment vs. logic issues within seconds
- Incremental confidence: Each passing step narrows the problem space
- Reusable pattern: Apply consistently across all Python spreadsheet tasks
常见问题
为什么要逐个测试导入?
这样能准确显示哪个库缺失或损坏,修复起来更快。
最小测试脚本做什么?
它会尝试读取电子表格并打印行数,以确认基本功能正常。
这只适用于 Excel 文件吗?
不。这些步骤也适用于 CSV 文件和其他表格数据。
详情
作者的原始描述
Systematic Python debugging workflow for spreadsheet tasks to isolate environment issues from script logic
repo: HKUDS/AgentPilot
热度
- GitHub 星标
- 7.8k
- 排名
- #12963
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …
同一仓库的更多技能
agentpilot
7.8k帮你的智能体准备任务并运行 AgentPilot 循环,逐步改进项目:循环会提出修改、测试修改并为其打分。
openspace
7.8k帮你的智能体设置 OpenSpace,这是一个用于存储和获取智能体技能的工具,并通过 MCP 将其连接到你的 AI 应用。
rsi-arena
7.8k帮你的智能体设置并运行标准 AI 基准测试,例如 AIME 和 Terminal-Bench,用来比较不同的改进方法。
experiment-guide
7.8k帮你的智能体规划小型实验、阅读实验结果并记录发现,同时研究如何改进一个程序。