Read, transform, analyze, and generate Excel and CSV files. Use when a user asks to open a spreadsheet, process Excel data, merge CSVs, create pivot tables, clean up data, convert between Excel and CSV, add formulas, filter rows, or generate reports from tabular data. Handles .xlsx, .xls, and .csv.
Read, transform, analyze, and generate Excel and CSV files using Python. This skill covers data loading, cleaning, filtering, aggregation, formula generation, and export to multiple formats.
When a user asks you to work with spreadsheets, Excel files, or CSV data, follow these steps:
import pandas as pd
# For Excel files
df = pd.read_excel("data.xlsx", sheet_name=0) # or sheet_name="Sheet1"
# For CSV files
df = pd.read_csv("data.csv")
# Show shape and preview
print(f"Shape: {df.shape[0]} rows x {df.shape[1]} columns")
print(f"Columns: {list(df.columns)}")
print(df.head())
Always print the shape, column names, and first few rows so the user can verify the data loaded correctly.
# Check for issues
print(f"Missing values:\n{df.isnull().sum()}")
print(f"\nDuplicates: {df.duplicated().sum()}")
print(f"\nData types:\n{df.dtypes}")
Report any issues found before proceeding with transformations.
Common operations:
Filtering:
filtered = df[df["status"] == "active"]
filtered = df[df["amount"] > 1000]
filtered = df[df["date"].between("2024-01-01", "2024-12-31")]
Aggregation:
summary = df.groupby("category").agg(
count=("id", "count"),
total=("amount", "sum"),
average=("amount", "mean")
).reset_index()
Pivot tables:
pivot = df.pivot_table(
values="revenue",
index="region",
columns="quarter",
aggfunc="sum",
margins=True
)
Cleaning:
df["name"] = df["name"].str.strip().str.title()
df["email"] = df["email"].str.lower()
df["date"] = pd.to_datetime(df["date"], errors="coerce")
df = df.drop_duplicates(subset=["id"])
df = df.dropna(subset=["required_field"])
# To Excel with formatting
with pd.ExcelWriter("output.xlsx", engine="openpyxl") as writer:
df.to_excel(writer, sheet_name="Data", index=False)
summary.to_excel(writer, sheet_name="Summary", index=False)
# To CSV
df.to_csv("output.csv", index=False)
Always summarize the operations performed, rows affected, and output file location.
User request: "Clean up customers.xlsx -- remove duplicates, fix phone formatting, and split into active/inactive sheets"
Actions taken:
customers.xlsx (2,340 rows, 8 columns)customers_clean.xlsx with two sheetsOutput:
Loaded: 2,340 rows x 8 columns
Removed: 156 duplicate rows (by email)
Fixed: 892 phone numbers reformatted
Split: 1,847 active, 337 inactive
Saved to customers_clean.xlsx:
- Sheet "Active": 1,847 rows
- Sheet "Inactive": 337 rows
User request: "Create a pivot table from sales.csv showing revenue by region and month"
Actions taken:
sales.csv (15,200 rows)sales_summary.xlsxOutput:
| Region | Jan | Feb | Mar | Total |
|-----------|----------|----------|----------|-----------|
| North | $45,200 | $52,100 | $48,900 | $146,200 |
| South | $38,700 | $41,300 | $44,600 | $124,600 |
| East | $51,900 | $49,800 | $55,200 | $156,900 |
| West | $42,100 | $46,700 | $43,500 | $132,300 |
| Total | $177,900 | $189,900 | $192,200 | $560,000 |
Saved to sales_summary.xlsx
pd.to_datetime() and specify the format when ambiguous (e.g., is 01/02/03 Jan 2 or Feb 1?).=SUM(B2:B100)) rather than computing values, so the spreadsheet stays dynamic.encoding="utf-8-sig" for Excel compatibility.npx skills add TerminalSkills/excel-processor下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer