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

spreadsheet-validated-execution

Skill này làm gì

Skill này hướng dẫn AI agent kiểm tra dữ liệu nguồn rồi chạy Python cho công việc bảng tính với openpyxl hoặc pandas. Nó dành cho những người có công việc Excel nhiều bước cần kiểm tra đầu vào cẩn thận.

Khi nào nên dùng

  • ✓Khi một công việc bảng tính đọc hoặc ghi file Excel phức tạp với nhiều sheet.
  • ✓Khi công thức, định dạng hoặc các phép biến đổi cần được áp dụng cho một workbook.
  • ✓Khi một công việc nhiều bước có thể vượt giới hạn bước của agent và nên được lưu thành script.

Liên kết skill

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/spreadsheet-direct-python-enhanced-enhanced/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/spreadsheet-direct-python-enhanced-enhanced/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

“Áp dụng định dạng và công thức cho workbook bán hàng của tôi, nhưng trước hết hãy xác nhận file nguồn có đó và đầy đủ.”

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

Cách hoạt động

Agent xác nhận nguồn có truy cập được và có cấu trúc như mong đợi. Sau đó nó viết phần xử lý Python thành một file script và chạy, dùng một nguồn dự phòng đã đặt tên nếu nguồn chính thất bại.

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.

Direct Python Execution for Spreadsheet Tasks

When to Use This Skill

Use this skill for spreadsheet operations that require verified source data:

  • Before processing: Verify data sources are accessible and contain expected data
  • Reading or writing complex Excel files with multiple sheets
  • Applying formulas, formatting, or data transformations
  • Working with openpyxl, pandas, or similar libraries
  • The operation involves multiple steps that could exceed agent step limits
  • You need precise control over error handling and debugging
  • Complex scripts benefit from file-based execution for better reliability

Critical: Data Source Validation First

Always validate data availability before attempting spreadsheet operations. This prevents wasted iterations on unavailable data.

Pre-Execution Validation Checklist

  1. Verify source accessibility: Test connection to data URLs/files before building processing scripts
  2. Confirm data format: Ensure source data matches expected structure (columns, sheets, file type)
  3. Check data completeness: Validate required fields/rows are present
  4. Identify fallback sources: Document alternative data sources if primary is unavailable

Validation Script Pattern

import sys
import os
from pathlib import Path

def validate_source(source_path, required_fields=None):
    """Validate data source before processing"""
    if not Path(source_path).exists():
        return False, f"Source file not found: {source_path}"
    
    try:
        # Check file is readable and non-empty
        if os.path.getsize(source_path) == 0:
            return False, "Source file is empty"
        
        if required_fields:
            # Validate structure using pandas
            import pandas as pd
            df = pd.read_excel(source_path, nrows=1)
            missing = set(required_fields) - set(df.columns)
            if missing:
                return False, f"Missing required columns: {missing}"
        
        return True, "Source validated"
    except Exception as e:
        return False, f"Validation error: {str(e)}"

# Usage
valid, message = validate_source('input.xlsx', ['ID', 'Date', 'Value'])
if not valid:
    print(f"ABORT: {message}", file=sys.stderr)
    sys.exit(1)
print(f"OK: {message}")

Handling Inaccessible Data Sources

When primary data sources are unavailable:

  1. Report clearly: Document the specific error (SSL, timeout, file not found)
  2. Attempt fallbacks: Check alternative sources in priority order:
    • Local cached copies of the data
    • Alternative API endpoints or URLs
    • Different file formats from the same source
    • Contact information for data provider
  3. Graceful degradation: If partial data is available, document what's missing
  4. Escalation protocol: For persistent failures, provide:
    • Exact error messages and timestamps
    • URLs/paths that were attempted
    • Workarounds already tried
    • Recommended next steps for human intervention

Example: Multi-Source Fallback Pattern

import sys
from pathlib import Path

sources = [
    'data/wells_current.xlsx',           # Primary: latest data
    'data/wells_backup.xlsx',            # Fallback 1: backup copy
    'data/wells_archive.xlsx',           # Fallback 2: archived version
    '/cached/wells_data.xlsx',           # Fallback 3: system cache
]

selected_source = None
for source in sources:
    if Path(source).exists():
        selected_source = source
        print(f"Using fallback source: {source}")
        break

if not selected_source:
    print("CRITICAL: No data sources available", file=sys.stderr)
    print("Attempted sources:", file=sys.stderr)
    for s in sources:
        print(f"  - {s}", file=sys.stderr)
    sys.exit(1)

# Proceed with selected_source
  • Reading or writing complex Excel files with multiple sheets
  • Applying formulas, formatting, or data transformations
  • Working with openpyxl, pandas, or similar libraries
  • The operation involves multiple steps that could exceed agent step limits
  • You need precise control over error handling and debugging
  • Complex scripts benefit from file-based execution for better reliability

Why Direct Execution?

The shell_agent tool can:

  • Hit maximum step limits on complex multi-step operations
  • Produce unexplained errors on formatting operations
  • Fail on intricate spreadsheet reads/writes due to iterative parsing
  • Fail to parse heredoc syntax correctly,
Câu hỏi thường gặp

Tại sao lưu công việc thành script?

Skill nói các script dạng file đáng tin cậy hơn cho công việc phức tạp nhiều bước.

Nó dùng thư viện nào?

Nó nêu openpyxl và pandas là các thư viện chính cho công việc bảng tính.

Nếu không truy cập được nguồn thì sao?

Agent ghi lại lỗi và dùng nguồn dự phòng nếu đã xác định một nguồn.

Chi tiết

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

Execute Python scripts with prerequisite data validation and fallback strategies for inaccessible sources

repo: HKUDS/AgentPilot

Độ phổ biến

Sao GitHub
7.8k
Vị trí xếp hạng
#13010
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ự