SKILL.md--- name: data-analysis description: Use this skill when the user uploads Excel (.xlsx/.xls) or CSV files and wants to perform data analysis, generate statistics, create summaries, pivot tables, SQL queries, or any form of structured data exploration. Supports multi-sheet Excel workbooks, aggregation, filtering, joins, and exporting results to CSV/JSON/Markdown. --- # Data Analysis Skill ## Overview This skill analyzes user-uploaded Excel/CSV files using DuckDB — an in-process analytical SQL engine. It supports schema inspection, SQL-based querying, statistical summaries, and result export, all through a single Python script. ## Environment setup Prepare the Python environment before running analyses. Install the required packages explicitly using the same interpreter that will run the script: ```bash python -m pip install duckdb openpyxl ``` If either package is missing, the script exits with a setup instruction; it does not invoke an installer or modify the environment. DuckDB's spatial extension is initialized only for `.xlsx` input. CSV and legacy `.xls` analysis do not install or load it, so they can run offline with an empty extension cache. Legacy Excel 97–2003 (`.xls`) workbooks additionally require: ```bash python -m pip install pandas xlrd ``` These optional packages are loaded only for `.xls` input. A missing package produces an explicit setup instruction. Legacy workbooks are read sheet by sheet with pandas' xlrd engine, preserving cell values (including literal `NA` strings and leading zeros in text identifiers) and treating empty cells as nulls. Columns with incompatible cell types, such as a date and a number, are stored as text with nulls preserved. Compatible numeric types still produce numeric columns. Completely empty sheets are skipped. The `.xlsx` reader continues to use openpyxl and DuckDB's spatial extension. A legacy workbook that cannot be opened is reported and skipped so remaining inputs can still be analyzed. The command fails if no input produces a table. ## Core Capabilities - Inspect Excel/CSV file structure (sheets, columns, types, row counts) - Execute arbitrary SQL queries against uploaded data - Generate statistical summaries (mean, median, stddev, percentiles, nulls) - Support multi-sheet Excel workbooks (each sheet becomes a table) - Export query results to CSV, JSON, or Markdown - Handle large files efficiently with DuckDB's columnar engine ## Workflow ### Step 1: Understand Requirements When a user uploads data files and requests analysis, identify: - **File location**: Path(s) to uploaded Excel/CSV files under `/mnt/user-data/uploads/` - **Analysis goal**: What insights the user wants (summary, filtering, aggregation, comparison, etc.) - **Output format**: How results should be presented (table, CSV export, JSON, etc.) - You don't need to check the folder under `/mnt/user-data` ### Step 2: Inspect File Struct