Csv excel merger

From OneWave-AI/claude-skills · View interactive version

Csv excel merger is an AI agent skill from the GitHub repository OneWave-AI/claude-skills. Merges, appends, joins, and deduplicates multiple CSV, TSV, and Excel files (including multi-sheet workbooks) with pandas - mapping mismatched column names to one schema, normalizing keys, resolving conflicting values, tracking which file each row came from, and verifying the row math. Use when the

How to use this skill

Skill file

CSV/Excel Merger

Combine tabular files into one clean output without silently losing, duplicating, or corrupting rows.

Workflow

Copy this checklist and track progress:

- [ ] 1. Profile inputs
- [ ] 2. Choose append vs join
- [ ] 3. Map columns and normalize keys
- [ ] 4. Merge and resolve conflicts
- [ ] 5. Verify row math
- [ ] 6. Write output and report
  1. Profile inputs. Run the bundled profiler first; it reports encoding, delimiter, rows, headers, candidate keys, and header overlap without changing anything:

```bash

python scripts/profile_inputs.py file1.csv file2.xlsx

```

Excel files are profiled per sheet. Confirm with the user which sheets count if a workbook has more than one.

  1. Choose the operation. This is the decision that most often goes wrong:
  1. Map columns and normalize keys. Build an explicit {original: unified} rename map per file (see references/merge_strategies.md for common variants) and show it to the user when any match is fuzzy. Normalize key columns before dedupe or join: strip whitespace, lowercase emails, strip non-digits from phones, unify date formats. Without this, A@x.com and a@x.com survive as two people.
  1. Merge. Read every file with dtype=str so IDs, ZIP codes, and phone numbers keep leading zeros, then convert specific columns afterward.

```python

import pandas as pd

frames = []

for path, rename in [("jan.csv", {"E-mail": "email"}), ("feb.xlsx", {"Email Address": "email"})]:

df = (pd.read_excel(path, dtype=str) if path.endswith((".xlsx", ".xls"))

else pd.read_csv(path, dtype=str, encoding="utf-8-sig", # use the profiler's encoding

keep_default_na=False))

df = df.rename(columns=rename)

df["email"] = df["email"].str.strip().str.lower()

df["source_file"] = path # lineage for every row

frames.append(df)

combined = pd.concat(frames, ignore_index=True, sort=False)

# Blank keys are not duplicates of each other: set them aside before deduping.

has_key = combined["email"].fillna("") != ""

# Later files win: list the most recent source last, then keep="last".

deduped = combined[has_key].drop_duplicates(subset=["email"], keep="last")

no_key = combined[~has_key]

merged = pd.concat([deduped, no_key], ignore_index=True)

```

For a join, make pandas enforce the relationship you expect so a duplicate key raises instead of multiplying rows:

```python

out = pd.merge(contacts, deals, on="email", how="left",

validate="one_to_one", indicator=True)

unmatched = out[out["_merge"] == "left_only"]

```

Conflict strategies (keep first/last/most complete, combine fields, flag for review) are in references/merge_strategies.md.

  1. Verify before reporting. Never hand back a merge without checking it:

```python

rows_in = sum(len(f) for f in frames)

assert len(merged) > 0, "merge produced an empty frame"

assert len(merged) <= rows_in, "more rows out than in: check the join keys"

assert deduped["email"].is_unique, "duplicate keys remain after dedupe"

print(f"in={rows_in} out={len(merged)} removed={rows_in - len(merged)} blank_keys={len(no_key)}")

print(merged["source_file"].value_counts())

```

Spot-check three removed duplicates by hand against the source files; the asserts prove the math, not that the right row won.

  1. Write output and report. Use the layout in references/output_template.md.

pandas version notes

Current pandas is 3.x (Python 3.11+). Differences that affect merges:

The code in this skill also runs on pandas 2.2.

Failure modes to check for

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.