DEV Community

Miprojt OpenClaw
Miprojt OpenClaw

Posted on

Dirty lead exports are a data problem, not a CRM problem

A CRM import usually fails before the CRM gets a chance to help. Duplicate emails, mixed phone formats, missing consent fields and campaign IDs scattered across columns make downstream reporting unreliable.

I built a small Python toolkit for that narrow job: turn a messy lead CSV into an auditable file before importing it anywhere.

The actual pipeline

Lead Ops does four things:

  1. Normalizes emails, phone numbers and column names.
  2. Validates and deduplicates records, keeping the source of each decision.
  3. Preserves campaign data such as UTM parameters and GCLID instead of dropping it during cleanup.
  4. Reconciles won sales so the cleaned leads can be compared with the original campaign data.

It is deliberately small and runs locally with Python. No external API, CRM credential or hosted database is required.

The interesting part is not a complex algorithm. It is the QA trail: a team should be able to see why a row was merged, rejected or flagged for review.

from lead_ops import process_csv

result = process_csv("leads-dirty.csv", "leads-clean.csv")
print(result.summary)
Enter fullscreen mode Exit fullscreen mode

A small, verifiable example

The included fixture has 12 source rows. The pipeline produces 10 unique valid leads and separates one duplicate and one invalid email. It also includes a sales-attribution example with 31,500 in won sales, so the output can be checked rather than just eyeballed.

The project includes the source code, unit tests, a dirty sample, the cleaned output and a QA report. That makes it useful as a starting point for an agency's recurring lead-hygiene job, not only as a one-off script.

Related: sprint exports

The same approach works for Jira exports. Sprint Ops computes velocity, cycle-time p50/p75/p90, blockers and recommendations without sending the issue data to another service.

I would rather keep these tools narrow and testable than turn them into another dashboard nobody checks. The source and tests are included so you can adapt the rules to your own exports.

Implementation and testing were AI-assisted; the demo metrics refer to the included synthetic fixtures, not client results.

Top comments (0)