[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6HX2544S0THR0FY3CRXC0P2":3,"skill-same:01M6HX2544S0THR0FY3CRXC0P2":71},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":43,"commitSha":44,"skillDirectory":45,"forksCount":46,"repositoryHtmlUrl":47,"repositoryHomepageUrl":6,"ownerHtmlUrl":48,"ownerBlogUrl":49,"ownerDescription":6,"updatedAt":50,"install":51,"resources":64},"01M6HX2544S0THR0FY3CRXC0P2","spreadsheet-source-validated",null,"Execute Python scripts for spreadsheet operations with mandatory source data validation and fallback protocols","HKUDS\u002FAgentPilot","HKUDS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F118165258?v=4","01M6HW8VRNZP64G0P4MVJW2KKQ","✨Data Intelligence Lab@HKU✨","01M6HW8VWZVHBRHYH3T330PFWV",8029,"MIT","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fbenchmarks\u002Fgdpval\u002Fskills\u002Fspreadsheet-direct-python-enhanced-enhanced-2e6773\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000004","电子表格","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37],"spreadsheet","source","spreadsheet source validated","python","validation","protocols","data","execute","operations","fallback","data validation","scripts","with","for","2026-11-10 10:12:30",false,"---\nname: spreadsheet-source-validated\ndescription: Execute Python scripts for spreadsheet operations with mandatory source data validation and fallback protocols\n---\n\n# Validated Python Execution for Spreadsheet Tasks\n\n## Pre-Execution Data Validation\n\n**CRITICAL**: Before attempting any spreadsheet operations, validate that your source data is accessible and complete.\n\n### Step 1: Verify Data Source Availability\n\n```python\nimport os\nimport sys\nfrom pathlib import Path\n\ndef validate_source_data(source_paths):\n    \"\"\"Validate all required data sources before processing.\"\"\"\n    missing = []\n    inaccessible = []\n    \n    for path in source_paths:\n        p = Path(path)\n        if not p.exists():\n            missing.append(str(path))\n        elif not os.access(path, os.R_OK):\n            inaccessible.append(str(path))\n    \n    if missing:\n        print(f\"ERROR: Missing data sources: {', '.join(missing)}\", file=sys.stderr)\n        return False\n    if inaccessible:\n        print(f\"ERROR: Inaccessible data sources: {', '.join(inaccessible)}\", file=sys.stderr)\n        return False\n    \n    print(f\"VALIDATED: {len(source_paths)} source(s) available\")\n    return True\n\n# Usage\nsources = ['input.xlsx', 'reference_data.csv']\nif not validate_source_data(sources):\n    sys.exit(1)\n```\n\n### Step 2: Verify Data Integrity\n\n```python\nimport pandas as pd\nfrom openpyxl import load_workbook\n\ndef validate_spreadsheet_integrity(file_path, required_sheets=None, required_columns=None):\n    \"\"\"Check spreadsheet structure before processing.\"\"\"\n    try:\n        # Check file is readable\n        wb = load_workbook(file_path, read_only=True)\n        \n        # Verify required sheets exist\n        if required_sheets:\n            missing_sheets = [s for s in required_sheets if s not in wb.sheetnames]\n            if missing_sheets:\n                print(f\"ERROR: Missing sheets: {missing_sheets}\", file=sys.stderr)\n                wb.close()\n                return False\n        \n        # Verify required columns (sample first sheet)\n        if required_columns:\n            ws = wb.active\n            headers = [cell.value for cell in ws[1]]\n            missing_cols = [c for c in required_columns if c not in headers]\n            if missing_cols:\n                print(f\"ERROR: Missing columns: {missing_cols}\", file=sys.stderr)\n                wb.close()\n                return False\n        \n        wb.close()\n        print(f\"VALIDATED: Spreadsheet structure OK\")\n        return True\n        \n    except Exception as e:\n        print(f\"ERROR: Cannot validate spreadsheet: {str(e)}\", file=sys.stderr)\n        return False\n```\n\n### Step 3: External Data Source Verification\n\nFor data retrieved from APIs, websites, or external services:\n\n```python\nimport requests\nfrom urllib3.exceptions import SSLError, MaxRetryError\n\ndef validate_external_source(url, timeout=30, max_retries=2):\n    \"\"\"Verify external data source is accessible.\"\"\"\n    for attempt in range(max_retries + 1):\n        try:\n            response = requests.head(url, timeout=timeout, allow_redirects=True)\n            if response.status_code == 200:\n                print(f\"VALIDATED: External source accessible ({url})\")\n                return True\n            else:\n                print(f\"WARNING: External source returned {response.status_code}\", file=sys.stderr)\n        except (SSLError, MaxRetryError, requests.ConnectionError) as e:\n            if attempt == max_retries:\n                print(f\"ERROR: External source inaccessible after {max_retries + 1} attempts: {url}\", file=sys.stderr)\n                return False\n            print(f\"RETRY {attempt + 1}\u002F{max_retries}: {str(e)}\", file=sys.stderr)\n    \n    return False\n```\n\n## When to Use This Skill\n\nUse validated Python execution for spreadsheet operations when:\n\n- **Source data must be verified** before processing begins\n- Reading or writing complex Excel files with multiple sheets\n- External data sources (APIs, websites) must be accessed first\n- Applying formulas, formatting, or data transformations\n- Working with `openpyxl`, `pandas`, or similar libraries\n- The operation involves multiple steps that could exceed agent step limits\n- You need precise control over error handling and debugging\n- **Fallback data sources** should be identified if primary sources fail\n\n## Handling Inaccessible Data Sources\n\n### Protocol for Failed Data Access\n\n1. **Document the failure** with specific error messages\n2. **Identify alternative sources** (see Alternative Sources section below)\n3. **Report the blockage** clearly before attempting workarounds\n4. **Limit retry attempts** to 3 before escalating\n\n### Alternative Data Source Identification\n\nWhen primary data sources are inaccessible:\n\n```python\nALTERNATIVE_SOURCES = {\n    'epa_water_data': [\n        'https:\u002F\u002Fdataservices.epa.illinois.gov\u002Fswap',  # Primary\n        'https:\u002F\u002Fwww.epa.gov\u002Fsafewater\u002Fdata-and-reports',  # Federal fallback\n        'https:\u002F\u002Fwaterdata.usgs.gov\u002Fnwis',  # USGS fallback\n    ],\n    'financial_data': [\n        'internal_database.xlsx',  # Primary\n        'backup_financial_data.csv',  # Local backup\n        'request_from_stakeholder',  # Manual acquisition\n    ]\n}\n\ndef try_alternative_sources(source_key):\n    \"\"\"Iterate through alternative sources until one succeeds.\"\"\"\n    alternatives = ALTERNATIVE_SOURCES.get(source_key, [])\n    \n    for i, source in enumerate(alternatives):\n        print(f\"Attempting alternative {i + 1}\u002F{len(alternatives)}: {source}\")\n        if source.startswith('http'):\n            if validate_external_source(source):\n                return source\n        else:\n            if Path(source).exists():\n                print(f\"SUCCESS: Alternative source found: {source}\")\n                return source\n    \n    print(f\"ERROR: All alternatives exhausted for {source_key}\", file=sys.stderr)\n    return None\n```\n\n### Error Reporting Protocol\n\n```python\ndef report_data_access_failure(source, error_type, alternatives_tried=0):\n    \"\"\"Standardized error reporting for data access failures.\"\"\"\n    error_report = {\n        'timestamp': datetime.now().isoformat(),\n        'source': source,\n        'error_type': error_type,\n        'alternatives_tried': alternatives_tried,\n        'action_required': 'Manual data acquisition or source configuration update'\n    }\n    \n    print(\"=\" * 60, file=sys.stderr)\n    print(\"DATA ACCESS FAILURE REPORT\", file=sys.stderr)\n    print(\"=\" * 60, file=sys.stderr)\n    for key, value in error_report.items():\n        print(f\"{key}: {value}\", file=sys.stderr)\n    print(\"=\" * 60, file=sys.stderr)\n    \n    return error_report\n```\n\n## Why Direct Execution?\n\nThe `shell_agent` tool can:\n\n- Hit maximum step limits on complex multi-step operations\n- Produce unexplained errors on formatting operations\n- Fail on intricate spreadsheet reads\u002Fwrites due to iterative parsing\n- Fail to parse heredoc syntax correctly, causing 'unknown error' failures\n\nDirect `run_shell` with Python is more reliable because it:\n\n- Executes in a single step with no iteration limits\n- Provides clearer, immediate error messages\n- Handles complex operations without step constraints\n- Gives full control over library imports and execution flow\n- Writing scripts to `.py` files first avoids shell_agent parsing issues with heredocs\n\n## How to Use\n\n### Recommended Pattern: Validate Then Execute\n\n```bash\n# Step 1: Write validation script\ncat > validate_sources.py \u003C\u003C 'EOF'\nimport sys\nfrom pathlib import Path\n\nsources = ['input.xlsx', 'config.json']\nmissing = [s for s in sources if not Path(s).exists()]\n\nif missing:\n    print(f\"BLOCKED: Missing sources: {missing}\", file=sys.stderr)\n    sys.exit(1)\n\nprint(\"VALIDATED: All sources available\")\nEOF\n\n# Step 2: Run validation\npython3 validate_sources.py || exit 1\n\n# Step 3: Write processing script\ncat > process_spreadsheet.py \u003C\u003C 'EOF'\nimport openpyxl\n# Your spreadsheet code here\nEOF\n\n# Step 4: Execute processing\npython3 process_spreadsheet.py\n\n# Step 5: Clean up (optional)\nrm validate_sources.py\n```\n\n### Complete Workflow Example\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"\nComplete workflow: Validate -> Process -> Report\n\"\"\"\nimport sys\nfrom pathlib import Path\nfrom datetime import datetime\nfrom openpyxl import load_workbook\n\ndef main():\n    # PHASE 1: Validation\n    print(f\"[{datetime.now().isoformat()}] Starting validation...\")\n    \n    source_file = 'input_data.xlsx'\n    if not Path(source_file).exists():\n        print(f\"ERROR: Source file not found: {source_file}\", file=sys.stderr)\n        # Check for alternatives\n        for alt in ['backup_input.xlsx', 'data_backup.csv']:\n            if Path(alt).exists():\n                print(f\"FALLBACK: Using alternative: {alt}\")\n                source_file = alt\n                break\n        else:\n            print(\"ERROR: No alternative sources available\", file=sys.stderr)\n            sys.exit(1)\n    \n    # PHASE 2: Processing\n    print(f\"[{datetime.now().isoformat()}] Processing {source_file}...\")\n    try:\n        wb = load_workbook(source_file)\n        ws = wb.active\n        \n        # Your operations here\n        for row in ws.iter_rows(min_row=2):\n            pass  # Process data\n        \n        wb.save('output.xlsx')\n        print(f\"SUCCESS: Processed {ws.max_row - 1} rows\")\n        \n    except Exception as e:\n        print(f\"ERROR: Processing failed: {str(e)}\", file=sys.stderr)\n        sys.exit(1)\n    \n    # PHASE 3: Cleanup\n    print(f\"[{datetime.now().isoformat()}] Complete\")\n\nif __name__ == '__main__':\n    main()\n```\n\n## Best Practices\n\n1. **ALWAYS validate sources first** before any spreadsheet operations\n2. **Prefer file-based execution** for complex scripts: write to `.py` file first, then execute via `run_shell`\n3. **Identify 2-3 alternative sources** for critical data before starting\n4. **Import only needed libraries** to reduce execution time\n5. **Print clear success\u002Ferror messages** for debugging\n6. **Save intermediate results** for complex multi-step transformations\n7. **Test with small data** before scaling to large spreadsheets\n8. **Use pandas for data manipulation** and openpyxl for formatting when both are needed\n9. **Clean up temporary script files** after execution if they won't be reused\n10. **Document all access failures** with timestamps and error details\n\n## When NOT to Use This Skill\n\n- Simple single-cell reads\u002Fwrites (use shell_agent or basic commands)\n- Operations that require interactive user input\n- Tasks where you need the agent to iteratively refine the approach\n- When source data is guaranteed available (skip validation overhead)\n\n## Common Libraries\n\n| Library | Best For |\n|---------|----------|\n| `openpyxl` | Reading\u002Fwriting .xlsx files, formatting, formulas |\n| `pandas` | Data manipulation, analysis, merging datasets |\n| `xlrd` | Reading older .xls files (read-only) |\n| `xlsxwriter` | Creating new .xlsx files with advanced formatting |\n| `requests` | Validating external API\u002Fdata sources |\n| `pathlib` | Cross-platform file path validation |\n\n## Troubleshooting\n\n**Issue**: Heredoc syntax fails with 'unknown error' when using shell_agent\n- **Solution**: Write the Python script to a `.py` file first, then execute it with `python3 script.py`. This pattern is significantly more reliable than inline heredoc execution when shell_agent is the executor.\n\n**Issue**: Source data validation fails\n- **Solution**: \n  1. Check file paths are absolute or relative to working directory\n  2. Verify file permissions with `ls -la`\n  3. Try alternative sources from your fallback list\n  4. Report the failure with complete error details before proceeding\n\n**Issue**: External data source inaccessible (SSL\u002Fproxy errors)\n- **Solution**:\n  1. Try HTTP instead of HTTPS if appropriate\n  2. Disable SSL verification temporarily: `requests.get(url, verify=False)`\n  3. Check proxy settings in environment variables\n  4. **After 3 failed attempts, switch to alternative source or report blockage**\n  5. Do NOT exhaust 30+ iterations on a single inaccessible source\n\n**Issue**: FileNotFoundError\n- **Solution**: Verify the file path is absolute or relative to the working directory; check for alternative backup files\n\n**Issue**: PermissionError\n- **Solution**: Ensure the file is not open in another application; check file permissions\n\n**Issue**: MemoryError on large files\n- **Solution**: Process data in chunks using pandas `chunksize` parameter\n\n**Issue**: Formatting not applying\n- **Solution**: Ensure you're modifying cell styles before saving, and use `.copy()` for style objects\n\n**Issue**: Data validation passes but processing fails\n- **Solution**: Add more detailed integrity checks (column types, value ranges, row counts)\n","# Validated Python Execution for Spreadsheet Tasks\n\n## Pre-Execution Data Validation\n\n**CRITICAL**: Before attempting any spreadsheet operations, validate that your source data is accessible and complete.\n\n### Step 1: Verify Data Source Availability\n\n```python\nimport os\nimport sys\nfrom pathlib import Path\n\ndef validate_source_data(source_paths):\n    \"\"\"Validate all required data sources before processing.\"\"\"\n    missing = []\n    inaccessible = []\n    \n    for path in source_paths:\n        p = Path(path)\n        if not p.exists():\n            missing.append(str(path))\n        elif not os.access(path, os.R_OK):\n            inaccessible.append(str(path))\n    \n    if missing:\n        print(f\"ERROR: Missing data sources: {', '.join(missing)}\", file=sys.stderr)\n        return False\n    if inaccessible:\n        print(f\"ERROR: Inaccessible data sources: {', '.join(inaccessible)}\", file=sys.stderr)\n        return False\n    \n    print(f\"VALIDATED: {len(source_paths)} source(s) available\")\n    return True\n\n# Usage\nsources = ['input.xlsx', 'reference_data.csv']\nif not validate_source_data(sources):\n    sys.exit(1)\n```\n\n### Step 2: Verify Data Integrity\n\n```python\nimport pandas as pd\nfrom openpyxl import load_workbook\n\ndef validate_spreadsheet_integrity(file_path, required_sheets=None, required_columns=None):\n    \"\"\"Check spreadsheet structure before processing.\"\"\"\n    try:\n        # Check file is readable\n        wb = load_workbook(file_path, read_only=True)\n        \n        # Verify required sheets exist\n        if required_sheets:\n            missing_sheets = [s for s in required_sheets if s not in wb.sheetnames]\n            if missing_sheets:\n                print(f\"ERROR: Missing sheets: {missing_sheets}\", file=sys.stderr)\n                wb.close()\n                return False\n        \n        # Verify required columns (sample first sheet)\n        if required_columns:\n            ws = wb.active\n            headers = [cell.value for cell in ws[1]]\n            missing_cols = [c for c in required_columns if c not in headers]\n            if missing_cols:\n                print(f\"ERROR: Missing columns: {missing_cols}\", file=sys.stderr)\n                wb.close()\n                return False\n        \n        wb.close()\n        print(f\"VALIDATED: Spreadsheet structure OK\")\n        return True\n        \n    except Exception as e:\n        print(f\"ERROR: Cannot validate spreadsheet: {str(e)}\", file=sys.stderr)\n        return False\n```\n\n### Step 3: External Data Source Verification\n\nFor data retrieved from APIs, websites, or external services:\n\n```python\nimport requests\nfrom urllib3.exceptions import SSLError, MaxRetryError\n\ndef validate_external_source(url, timeout=30, max_retries=2):\n    \"\"\"Verify external data source is accessible.\"\"\"\n    for attempt in range(max_retries + 1):\n        try:\n            response = requests.head(url, timeout=timeout, allow_redirects=True)\n            if response.status_code == 200:\n                print(f\"VALIDATED: External source accessible ({url})\")\n                return True\n            else:\n                print(f\"WARNING: External source returned {response.status_code}\", file=sys.stderr)\n        except (SSLError, MaxRetryError, requests.ConnectionError) as e:\n            if attempt == max_retries:\n                print(f\"ERROR: External source inaccessible after {max_retries + 1} attempts: {url}\", file=sys.stderr)\n                return False\n            print(f\"RETRY {attempt + 1}\u002F{max_retries}: {str(e)}\", file=sys.stderr)\n    \n    return False\n```\n\n## When to Use This Skill\n\nUse validated Python execution for spreadsheet operations when:\n\n- **Source data must be verified** before processing begins\n- Reading or writing complex Excel files with multiple sheets\n- External data sources (APIs, websites) must be accessed first\n- Applying formulas, formatting, or data transformations\n- Working with `openpyxl`, `pandas`, or similar libraries\n- The operation involves multiple steps that could exceed agent step limits\n- You need precise control over error handling and debugging\n- **Fallback data sources** should be identified if primary sources fail\n\n## Handling Inaccessible Data Sources\n\n### Protocol for Failed Data Access\n\n1. **Document the failure** with specific error messages\n2. **Identify alternative sources** (see Alternative Sources section below)\n3. **Report the blockage** clearly before attempting workarounds\n4. **Limit retry attempts** to 3 before escalating\n\n### Alternative Data Source Identification\n\nWhen primary data sources are inaccessible:\n\n```python\nALTERNATIVE_SOURCES = {\n    'epa_water_data': [\n        'https:\u002F\u002Fdataservices.epa.illinois.gov\u002Fswap',  # Primary\n        'https:\u002F\u002Fwww.epa.gov\u002Fsafewater\u002Fdata-and-reports',  # Federal fallback\n        'https:\u002F\u002Fwaterdata.usgs.gov\u002Fnwis',  # USGS fallback\n    ],\n    'financial_data': [\n        'internal_database.xlsx',  # Primary\n        'backup_financial_data.csv',  # Local backup\n        'request_from_stakeholder',  # Manual acquisition\n    ]\n}\n\ndef try_alternative_sources(source_key):\n    \"\"\"Iterate through alternative sources until one succeeds.\"\"\"\n    alternatives = ALTERNATIVE_SOURCES.get(source_key, [])\n    \n    for i, source in enumerate(alternatives):\n        print(f\"Attempting alternative {i + 1}\u002F{len(alternatives)}: {source}\")\n        if source.startswith('http'):\n            if validate_external_source(source):\n                return source\n        else:\n            if Path(source).exists():\n                print(f\"SUCCESS: Alternative source found: {source}\")\n                return source\n    \n    print(f\"ERROR: All alternatives exhausted for {source_key}\", file=sys.stderr)\n    return None\n```\n\n### Error Reporting Protocol\n\n```python\ndef report_data_access_failure(source, error_type, alternatives_tried=0):\n    \"\"\"Standardized error reporting for data access failures.\"\"\"\n    error_report = {\n        'timestamp': datetime.now().isoformat(),\n        'source': source,\n        'error_type': error_type,\n        'alternatives_tried': alternatives_tried,\n        'action_required': 'Manual data acquisition or source configuration update'\n    }\n    \n    print(\"=\" * 60, file=sys.stderr)\n    print(\"DATA ACCESS FAILURE REPORT\", file=sys.stderr)\n    print(\"=\" * 60, file=sys.stderr)\n    for key, value in error_report.items():\n        print(f\"{key}: {value}\", file=sys.stderr)\n    print(\"=\" * 60, file=sys.stderr)\n    \n    return error_report\n```\n\n## Why Direct Execution?\n\nThe `shell_agent` tool can:\n\n- Hit maximum step limits on complex multi-step operations\n- Produce unexplained errors on formatting operations\n- Fail on intricate spreadsheet reads\u002Fwrites due to iterative parsing\n- Fail to parse heredoc syntax correctly, causing 'unknown error' failures\n\nDirect `run_shell` with Python is more reliable because it:\n\n- Executes in a single step with no iteration limits\n- Provides clearer, immediate error messages\n- Handles complex operations without step constraints\n- Gives full control over library imports and execution flow\n- Writing scripts to `.py` files first avoids shell_agent parsing issues with heredocs\n\n## How to Use\n\n### Recommended Pattern: Validate Then Execute\n\n```bash\n# Step 1: Write validation script\ncat > validate_sources.py \u003C\u003C 'EOF'\nimport sys\nfrom pathlib import Path\n\nsources = ['input.xlsx', 'config.json']\nmissing = [s for s in sources if not Path(s).exists()]\n\nif missing:\n    print(f\"BLOCKED: Missing sources: {missing}\", file=sys.stderr)\n    sys.exit(1)\n\nprint(\"VALIDATED: All sources available\")\nEOF\n\n# Step 2: Run validation\npython3 validate_sources.py || exit 1\n\n# Step 3: Write processing script\ncat > process_spreadsheet.py \u003C\u003C 'EOF'\nimport openpyxl\n# Your spreadsheet code here\nEOF\n\n# Step 4: Execute processing\npython3 process_spreadsheet.py\n\n# Step 5: Clean up (optional)\nrm validate_sources.py\n```\n\n### Complete Workflow Example\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"\nComplete workflow: Validate -> Process -> Report\n\"\"\"\nimport sys\nfrom pathlib import Path\nfrom datetime import datetime\nfrom openpyxl import load_workbook\n\ndef main():\n    # PHASE 1: Validation\n    print(f\"[{datetime.now().isoformat()}] Starting validation...\")\n    \n    source_file = 'input_data.xlsx'\n    if not Path(source_file).exists():\n        print(f\"ERROR: Source file not found: {source_file}\", file=sys.stderr)\n        # Check for alternatives\n        for alt in ['backup_input.xlsx', 'data_backup.csv']:\n            if Path(alt).exists():\n                print(f\"FALLBACK: Using alternative: {alt}\")\n                source_file = alt\n                break\n        else:\n            print(\"ERROR: No alternative sources available\", file=sys.stderr)\n            sys.exit(1)\n    \n    # PHASE 2: Processing\n    print(f\"[{datetime.now().isoformat()}] Processing {source_file}...\")\n    try:\n        wb = load_workbook(source_file)\n        ws = wb.active\n        \n        # Your operations here\n        for row in ws.iter_rows(min_row=2):\n            pass  # Process data\n        \n        wb.save('output.xlsx')\n        print(f\"SUCCESS: Processed {ws.max_row - 1} rows\")\n        \n    except Exception as e:\n        print(f\"ERROR: Processing failed: {str(e)}\", file=sys.stderr)\n        sys.exit(1)\n    \n    # PHASE 3: Cleanup\n    print(f\"[{datetime.now().isoformat()}] Complete\")\n\nif __name__ == '__main__':\n    main()\n```\n\n## Best Practices\n\n1. **ALWAYS validate sources first** before any spreadsheet operations\n2. **Prefer file-based execution** for complex scripts: write to `.py` file first, then execute via `run_shell`\n3. **Identify 2-3 alternative sources** for critical data before starting\n4. **Import only needed libraries** to reduce execution time\n5. **Print clear success\u002Ferror messages** for debugging\n6. **Save intermediate results** for complex multi-step transformations\n7. **Test with small data** before scaling to large spreadsheets\n8. **Use pandas for data manipulation** and openpyxl for formatting when both are needed\n9. **Clean up temporary script files** after execution if they won't be reused\n10. **Document all access failures** with timestamps and error details\n\n## When NOT to Use This Skill\n\n- Simple single-cell reads\u002Fwrites (use shell_agent or basic commands)\n- Operations that require interactive user input\n- Tasks where you need the agent to iteratively refine the approach\n- When source data is guaranteed available (skip validation overhead)\n\n## Common Libraries\n\n| Library | Best For |\n|---------|----------|\n| `openpyxl` | Reading\u002Fwriting .xlsx files, formatting, formulas |\n| `pandas` | Data manipulation, analysis, merging datasets |\n| `xlrd` | Reading older .xls files (read-only) |\n| `xlsxwriter` | Creating new .xlsx files with advanced formatting |\n| `requests` | Validating external API\u002Fdata sources |\n| `pathlib` | Cross-platform file path validation |\n\n## Troubleshooting\n\n**Issue**: Heredoc syntax fails with 'unknown error' when using shell_agent\n- **Solution**: Write the Python script to a `.py` file first, then execute it with `python3 script.py`. This pattern is significantly more reliable than inline heredoc execution when shell_agent is the executor.\n\n**Issue**: Source data validation fails\n- **Solution**: \n  1. Check file paths are absolute or relative to working directory\n  2. Verify file permissions with `ls -la`\n  3. Try alternative sources from your fallback list\n  4. Report the failure with complete error details before proceeding\n\n**Issue**: External data source inaccessible (SSL\u002Fproxy errors)\n- **Solution**:\n  1. Try HTTP instead of HTTPS if appropriate\n  2. Disable SSL verification temporarily: `requests.get(url, verify=False)`\n  3. Check proxy settings in environment variables\n  4. **After 3 failed attempts, switch to alternative source or report blockage**\n  5. Do NOT exhaust 30+ iterations on a single inaccessible source\n\n**Issue**: FileNotFoundError\n- **Solution**: Verify the file path is absolute or relative to the working directory; check for alternative backup files\n\n**Issue**: PermissionError\n- **Solution**: Ensure the file is not open in another application; check file permissions\n\n**Issue**: MemoryError on large files\n- **Solution**: Process data in chunks using pandas `chunksize` parameter\n\n**Issue**: Formatting not applying\n- **Solution**: Ensure you're modifying cell styles before saving, and use `.copy()` for style objects\n\n**Issue**: Data validation passes but processing fails\n- **Solution**: Add more detailed integrity checks (column types, value ranges, row counts)\n",{"name":5,"description":7},"main","6b84b0689ca0d9e7b1e4061188ff6b60758e0f8a","openspace\u002Fbenchmarks\u002Fgdpval\u002Fskills\u002Fspreadsheet-direct-python-enhanced-enhanced-2e6773",944,"https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot","https:\u002F\u002Fgithub.com\u002FHKUDS","https:\u002F\u002Fsites.google.com\u002Fview\u002Fchaoh","2026-11-12 22:26:39",{"source":8,"skillName":5,"commands":52,"prompt":62,"zipAvailable":63},[53,56,59],{"tool":54,"command":55},"npx","npx skills add HKUDS\u002FAgentPilot --skill spreadsheet-source-validated",{"tool":57,"command":58},"bunx","bunx skills add HKUDS\u002FAgentPilot --skill spreadsheet-source-validated",{"tool":60,"command":61},"pnpm","pnpm dlx skills add HKUDS\u002FAgentPilot --skill spreadsheet-source-validated","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fbenchmarks\u002Fgdpval\u002Fskills\u002Fspreadsheet-direct-python-enhanced-enhanced-2e6773\u002FSKILL.md",true,[65],{"path":66,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":69,"sourceHtmlUrl":70},".skill_id","OTHER","其他",64,"https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fbenchmarks\u002Fgdpval\u002Fskills\u002Fspreadsheet-direct-python-enhanced-enhanced-2e6773\u002F.skill_id",[72,91,110,133,156,178],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":38},"01M6HYB297NDABRERJRVG0K8R0","agentpilot","Set up AgentPilot and use its single entry to prepare missing inputs and run configured RSI experiments. Use when the user requests AgentPilot installation or work with AgentPilot.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fplugins\u002Fagentpilot\u002Fskills\u002Fagentpilot\u002FSKILL.md",[],[74,79,80,36,81,82,83,84,85,86,87,88,89,90],"prepare","requests","missing","installation","rsi","up","use","user","work","SET","run","experiments",{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":38},"01M6HYAYWXTTE1J7DJM0MFNQ4H","remember","Review auto-memory entries and propose promotions to OPENSPACE.md, OPENSPACE.local.md, or retained auto-memory topics; detect duplicates, stale facts, conflicts, and ambiguous entries before making changes.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fskills\u002Fremember\u002FSKILL.md",[],[93,98,99,100,101,102,103,104,105,106,107,108,109],"memory","review","auto","openspace","changes","facts","detect","entries","local","conflicts","stale","duplicates",{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":119,"publishedAt":38},"01M6HYAVMPM4SBDV60R2B5HPV8","skill-discovery","Search reusable OpenSpace skills locally, and browse cloud packages step by step when a cloud skill may help. Reusing proven skills saves tokens, improves reliability, and extends your capabilities beyond built-in tools.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fhost_skills\u002Fskill-discovery\u002FSKILL.md",[116],{"categoryNo":117,"categoryName":118,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[120,121,122,101,123,124,125,126,127,128,129,130,131,132],"skill discovery","discovery","reusable","step by step","tokens","packages","help","cloud","reliability","capabilities","browse","search","Tools",{"skillNo":134,"name":135,"nameZh":6,"description":136,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":137,"categories":138,"keywords":140,"publishedAt":38},"01M6HYAR811B3RB0M50RBEDGN6","delegate-task","Delegate tasks to OpenSpace — a full-stack autonomous worker for coding, DevOps, web research, and desktop automation, backed by an extensive MCP tool and skill library. Skills auto-improve through use, reducing token consumption over time. A cloud community lets agents share and collectively evolve reusable skills.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fhost_skills\u002Fdelegate-task\u002FSKILL.md",[139],{"categoryNo":117,"categoryName":118,"taxonomyType":21,"taxonomyTypeDesc":22},[141,142,143,101,144,145,146,147,148,122,100,85,149,150,151,37,152,153,154,155],"delegate","task","delegate task","time","improve","desktop automation","worker","community","autonomous","tool","stack","share","tasks","automation","MCP",{"skillNo":157,"name":158,"nameZh":6,"description":159,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":160,"categories":161,"keywords":162,"publishedAt":38},"01M6HYAM9FSGV6E52AYENDQXYH","write-special-chars-ts-check","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, plus a reliable TypeScript type-checking step that filters output to only the newly-written files to avoid being misled by pre-existing errors.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-ts-check\u002FSKILL.md",[],[163,164,165,166,167,168,169,170,171,27,172,173,174,175,37,176,177],"write special chars ts check","write","check","type","files","filters","only","template","file","typescript","output","Existing","type-checking","errors","script",{"skillNo":179,"name":180,"nameZh":6,"description":181,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":182,"categories":183,"keywords":184,"publishedAt":38},"01M6HYAH05HGV7SVWSVR8PJRQD","write-special-chars-readback","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, with mandatory post-write verification via read_file and cleanup of \u002Ftmp helper scripts.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-readback\u002FSKILL.md",[],[185,186,164,36,37,177,187,188,189,35,190,170,171,191,192,27],"write special chars readback","readback","helper","post","via","read","verification","cleanup"]