Chuyển đến nội dung
Skillpedia
Phân tích và bảng tính7.8k · #12963

python-spreadsheet-debug

Skill này làm gì

Skill này cho AI agent một loạt kiểm tra có thứ tự cho công việc bảng tính bằng Python. Nó dành cho những người có script bảng tính bị lỗi và cần biết vấn đề nằm ở môi trường hay ở script.

Khi nào nên dùng

  • ✓Khi một script bảng tính lỗi và đầu ra shell khó đọc.
  • ✓Khi bạn nghi Python hoặc một thư viện bị thiếu hoặc sai phiên bản.
  • ✓Khi bạn muốn chạy thử nhỏ để xác nhận file đọc được trước khi chạy toàn bộ công việc.

Liên kết skill

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/python-spreadsheet-debug/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/python-spreadsheet-debug/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Script bảng tính của tôi lỗi mà không rõ lý do. Hãy kiểm tra Python và pandas có hoạt động không, rồi thử đọc file.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent kiểm tra Python nào đang được dùng và phiên bản của nó, rồi import riêng từng thư viện cần thiết. Tiếp theo, nó chạy một script thử nghiệm ngắn để đọc file và in bản tóm tắt trước khi công việc đầy đủ chạy.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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_shell returns 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
Câu hỏi thường gặp

Tại sao phải import từng thư viện riêng?

Cách này cho thấy chính xác thư viện nào bị thiếu hoặc hỏng, nên việc sửa lỗi nhanh hơn.

Script thử nghiệm tối thiểu làm gì?

Nó cố đọc file bảng tính và in số hàng, điều này xác nhận các thao tác cơ bản hoạt động.

Điều này chỉ áp dụng cho file Excel thôi sao?

Không, các bước này cũng áp dụng cho file CSV và các dữ liệu dạng bảng khác.

Chi tiết

Mô tả gốc của tác giả

Systematic Python debugging workflow for spreadsheet tasks to isolate environment issues from script logic

repo: HKUDS/AgentPilot

Độ phổ biến

Sao GitHub
7.8k
Vị trí xếp hạng
#12963
Giấy phép
MIT
Cập nhật
1/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự