Incremental audio production with duration mismatch handling, adaptive stem extension, and pre-mix alignment verification
中文简介正在准备中。当前显示原文说明。
Create and process Excel files, PDF checklists, and structured reports by running Python scripts directly. The skill covers multiple sheets, formulas, formatting, data transformations, and error handling for document workflows with several steps.
中文简介正在准备中。当前显示英语简介。
Use direct Python execution for reliable document creation including spreadsheets, PDFs, and structured reports
安装前可以查看交给 AI 代理的指令内容。
Use direct run_shell with Python scripts for document operations when:
openpyxl, pandas, reportlab, FPDF, or similar librariesThe shell_agent tool can:
Direct run_shell with Python is more reliable because it:
.py files first avoids shell_agent parsing issues with heredocsWhen web research tools (search_web, read_webpage) fail or return 'unknown error':
run_shell pattern to generate documents even without web-sourced content.Example contingency workflow for pharmacy compliance:
# When web research fails, proceed with established regulatory knowledge
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
checklist_items = [
"Verify pharmacist license is current and displayed",
"Maintain controlled substance inventory logs",
"Ensure proper storage temperatures for medications",
"Keep patient counseling records for controlled substances",
"Display required pharmacy signage and notices"
]
# Generate PDF using these standard compliance items
This approach was successfully used in task 045aba2e-4093-42aa-ab7f-159cc538278c_phase2 where all web tools failed but pharmacy compliance PDFs were still created successfully.
For complex multi-line scripts, especially when using shell_agent as executor:
# Step 1: Write the Python script to a file
cat > generate_document.py << 'EOF'
import openpyxl
from openpyxl import Workbook
# Your document code here
wb = openpyxl.load_workbook('file.xlsx')
# ... operations ...
wb.save('output.xlsx')
print('Success')
EOF
# Step 2: Execute the script
python3 generate_document.py
For short, simple scripts when NOT using shell_agent as the executor:
python3 << 'EOF'
import pandas as pd
df = pd.read_excel('input.xlsx')
df.to_excel('output.xlsx', index=False)
print('Done')
EOF
Write to file first, then execute:
import pandas as pd
# Load data from specific sheet
df = pd.read_excel('input.xlsx', sheet_name='Revenue')
# Apply transformations
df['Net_Revenue'] = df['Gross_Revenue'] * (1 - df['Tax_Rate'])
# Save results
df.to_excel('output.xlsx', index=False, sheet_name='Processed')
from openpyxl import load_workbook
wb = load_workbook('tour_data.xlsx')
# Iterate through sheets
for sheet_name in wb.sheetnames:
ws = wb[sheet_name]
# Apply formatting or calculations
for row in ws.iter_rows(min_row=2, max_col=5):
# Process cells
pass
wb.save('tour_data_processed.xlsx')
Write to file first, then execute:
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from reportlab.lib.units import inch
def create_checklist(filename, items):
c = canvas.Canvas(filename, pagesize=letter)
width, height = letter
# Title
c.setFont("Helvetica-Bold", 20)
c.drawString(1*inch, height - 1*inch, "Task Checklist")
# Items
c.setFont("Helvetica", 14)
y_position = height - 1.5*inch
for i, item in enumerate(items, 1):
checkbox = "☐" # Empty checkbox
c.drawString(1*inch, y_position, f"{checkbox} {item}")
y_position -= 0.3*inch
c.save()
print(f"Created {filename} with {len(items)} items")
# Usage
items = ["Review requirements", "Complete analysis", "Submit report", "Follow up"]
create_checklist("checklist.pdf", items)
from fpdf import FPDF
class PDF(FPDF):
def header(self):
self.set_font('Arial', 'B', 15)
self.cell(0, 10, 'Monthly Report', 0, 1, 'C')
self.ln(10)
def footer(self):
self.set_y(-15)
self.set_font('Arial', 'I', 8)
self.cell(0, 10, f'Page {self.page_no()}', 0, 0, 'C')
def create_report(filename, data):
pdf = PDF()
pdf.add_page()
pdf.set_font('Arial', '', 12)
# Add content
for section, content in data.items():
pdf.set_font('Arial', 'B', 12)
pdf.cell(0, 10, section, 0, 1)
pdf.set_font('Arial', '', 12)
pdf.multi_cell(0, 8, content)
pdf.ln(5)
pdf.output(filename)
print(f"Report saved to {filename}")
# Usage
data = {
"Executive Summary": "This report covers Q4 performance metrics.",
"Key Findings": "Revenue increased by 15% compared to Q3.",
"Recommendations": "Continue current strategy with minor adjustments."
}
create_report("report.pdf", data)
import pandas as pd
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle
from reportlab.lib import colors
# Step 1: Process spreadsheet data
df = pd.read_excel('sales_data.xlsx')
summary = df.groupby('Region')['Revenue'].sum().reset_index()
# Step 2: Generate PDF report
doc = SimpleDocTemplate("sales_report.pdf", pagesize=letter)
elements = []
# Create table from data
data = [['Region', 'Revenue']]
for _, row in summary.iterrows():
data.append([row['Region'], f"${row['Revenue']:,.2f}"])
table = Table(data)
table.setStyle(TableStyle([
('BACKGROUND', (0, 0), (-1, 0), colors.grey),
('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke),
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
('GRID', (0, 0), (-1, -1), 1, colors.black),
]))
elements.append(table)
doc.build(elements)
print("PDF report generated successfully")
Write to file first, then execute:
import sys
from openpyxl import load_workbook
try:
wb = load_workbook('data.xlsx')
ws = wb.active
# Your operations here
value = ws['A1'].value
wb.save('output.xlsx')
print(f"Success: Processed {ws.max_row} rows")
except Exception as e:
print(f"Error: {str(e)}", file=sys.stderr)
sys.exit(1)
.py file first, then execute via run_shell| Library | Best For |
|---|---|
openpyxl | Reading/writing .xlsx files, formatting, formulas |
pandas | Data manipulation, analysis, merging datasets |
xlrd | Reading older .xls files (read-only) |
xlsxwriter | Creating new .xlsx files with advanced formatting |
| Library | Best For |
|---|---|
reportlab | Professional PDF reports with complex layouts |
FPDF | Simple PDF generation with basic formatting |
PyPDF2 / pypdf | Reading, merging, splitting existing PDFs |
pdfplumber | Extracting text and tables from PDFs |
Issue: Heredoc syntax fails with 'unknown error' when using shell_agent
.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.Issue: FileNotFoundError
os.getcwd() to check current directory if needed.Issue: PermissionError
Issue: MemoryError on large files
chunksize parameter. For PDFs, generate in sections and merge.Issue: Formatting not applying
.copy() for style objects in openpyxl.Issue: PDF text rendering issues
DejaVuSans for Unicode support in reportlab).Issue: Agent fails before first iteration (0 steps)
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Incremental audio production with duration mismatch handling, adaptive stem extension, and pre-mix alignment verification
中文简介正在准备中。当前显示原文说明。
Incremental audio production with duration alignment handling, per-stem verification, and adaptive extension strategies
中文简介正在准备中。当前显示原文说明。
Build serverless endpoints that relay external API requests for a dashboard while keeping API keys on the server. Includes Vercel examples for input checks, caching, cross-origin access, and consistent JSON responses.
中文简介正在准备中。当前显示英语简介。
End-to-end audio production workflow with stems, effects, archiving, and verification
中文简介正在准备中。当前显示原文说明。
Keep document creation moving when web searches and page retrieval repeatedly fail. The skill preserves the original task, uses the model’s existing knowledge, and clearly identifies information that could not be checked against external sources.
中文简介正在准备中。当前显示英语简介。
Fallback pattern for executing Python code when execute_code_sandbox fails
中文简介正在准备中。当前显示原文说明。