A collection of standalone Python scripts that handle the Excel tasks you keep putting off.
| Script | What it does |
|---|---|
excel_merger.py |
Merge multiple .xlsx / .csv files into one |
duplicate_finder.py |
Find exact and near-duplicate rows with color highlighting |
data_cleaner.py |
Standardize dates, casing, phones, whitespace — with a change log |
sheet_splitter.py |
Split one sheet into separate files by column value |
pivot_report.py |
Generate a formatted multi-tab summary report with charts |
pip install pandas openpyxl rapidfuzz matplotlibRequires Python 3.10+ (uses str | None union syntax).
Merge all .xlsx and .csv files in a folder into one output file.
# Basic merge
python excel_merger.py --input ./reports --output merged.xlsx
# Add a column showing which file each row came from
python excel_merger.py --input ./reports --output merged.xlsx --source-column "Source File"
# Read from a specific sheet name in each file
python excel_merger.py --input ./reports --output merged.xlsx --sheet "Data"
# Skip the summary tab
python excel_merger.py --input ./reports --output merged.xlsx --no-summaryOutput: merged.xlsx with a Merged Data tab and a Summary tab (row counts per file).
Flag exact and fuzzy/near-duplicate rows based on key columns you define.
# Check for duplicates on Email column
python duplicate_finder.py --input customers.xlsx --key-cols "Email"
# Check multiple columns together as a composite key
python duplicate_finder.py --input customers.xlsx --key-cols "First Name" "Last Name" "Phone"
# Adjust fuzzy sensitivity (default 85; lower = more matches)
python duplicate_finder.py --input customers.xlsx --key-cols "Name" --fuzzy-threshold 75
# Custom output path
python duplicate_finder.py --input data.xlsx --key-cols "Email" --output flagged_output.xlsxOutput: Annotated Excel file with _dup_group, _dup_type, _dup_score columns.
- Orange rows = exact duplicates
- Yellow rows = near-duplicates (fuzzy match)
Apply cleaning rules to a messy export. Outputs a cleaned file and a full change log.
# Run with default rules (strip whitespace, remove blank rows)
python data_cleaner.py --input export.xlsx
# Use a JSON config file to define column-specific rules
python data_cleaner.py --input export.xlsx --output cleaned.xlsx --config rules.json
# Read from a CSV
python data_cleaner.py --input export.csv --output cleaned.xlsxExample rules.json:
{
"strip_whitespace": ["Name", "Email", "Address"],
"title_case": ["Name", "City"],
"lower_case": ["Email"],
"upper_case": ["Country Code"],
"date_format": {"columns": ["Date", "DOB"], "output_format": "%Y-%m-%d"},
"phone_normalize": ["Phone", "Mobile"],
"remove_blank_rows": true,
"remove_duplicates": ["Email"]
}Output: Cleaned Data tab + Change Log tab showing every cell that was modified.
Split a master sheet into one file per unique value in a column.
# Split by Region column
python sheet_splitter.py --input master.xlsx --split-col "Region"
# Custom output folder and filename template
python sheet_splitter.py --input sales.xlsx --split-col "Department" \
--output-dir ./monthly_splits \
--name-template "Sales_{value}_{date}.xlsx"
# Send each file as an email attachment (requires SMTP config in script)
python sheet_splitter.py --input data.xlsx --split-col "Region" \
--email-map emails.csv \
--smtp-user you@company.com --smtp-pass yourpasswordFilename template placeholders: {value}, {date}, {datetime}
emails.csv format:
Value,Email
North,north@company.com
South,south@company.com
Output: One .xlsx per unique column value + _manifest.csv listing all output files.
Generate a formatted summary report from raw transaction or data rows.
# Basic usage — group by Category, sum Amount, parse Date
python pivot_report.py --input transactions.xlsx \
--date-col "Date" --value-col "Amount" --group-cols "Category"
# Multiple grouping columns
python pivot_report.py --input sales.xlsx \
--date-col "Sale Date" --value-col "Revenue" --group-cols "Product" "Region"
# Show top 20 instead of default top 10
python pivot_report.py --input data.xlsx \
--date-col "Date" --value-col "Amount" --group-cols "Category" --top-n 20Output tabs:
- Overview — key stats (total, count, average, date range)
- By Group — total/count/avg/min/max per group + % of total + bar chart
- Monthly Trend — month-by-month totals + MoM % change + line chart
- Top N — top N groups by total value
- Year-over-Year — yearly comparison matrix
