DEV Community

Ujjwal Dubey
Ujjwal Dubey

Posted on

Find the Rework Loops: Counting Repeat Edits per Record in an Exported Sheet With Python

When a small team says "this process is slow", the cause is often not speed. It is rework: the same order, quote or ticket gets touched again and again because a rule is unclear.

You can measure that before you spend anything on AI. It is one of the most useful numbers when you audit a business workflow ahead of an AI purchase, and you only need an exported change log.

The input

Most tools can export an activity or change history. Shape it into a CSV like this:

record_id,changed_at,changed_by,field
ORD-101,2026-10-05T10:02,asha,status
ORD-101,2026-10-05T10:40,ravi,delivery_date
ORD-101,2026-10-06T09:15,asha,delivery_date
ORD-102,2026-10-05T11:00,asha,status
Enter fullscreen mode Exit fullscreen mode

The script

import csv
from collections import defaultdict
from datetime import datetime

edits = defaultdict(list)
with open("changes.csv", newline="") as f:
    for row in csv.DictReader(f):
        ts = datetime.fromisoformat(row["changed_at"])
        edits[row["record_id"]].append((ts, row["changed_by"], row["field"]))

report = []
for rid, rows in edits.items():
    rows.sort()
    fields = defaultdict(int)
    people = set()
    for _, who, field in rows:
        fields[field] += 1
        people.add(who)
    repeated = {k: v for k, v in fields.items() if v > 1}
    if repeated:
        report.append((rid, len(rows), len(people), repeated))

report.sort(key=lambda r: r[1], reverse=True)
for rid, total, people, repeated in report[:20]:
    print(f"{rid}: {total} edits by {people} people; repeated fields: {repeated}")
Enter fullscreen mode Exit fullscreen mode

Reading the output

  • The same field edited by different people usually means two people think they own it. Fix ownership first.
  • A date field edited many times often means customers change plans and there is no rule for how far ahead changes are allowed.
  • A status field that flips back and forth means the steps are not clear, or one step is being skipped and caught later.

None of these are solved by adding a model. Write the rule, agree who owns the field, then check the log again.

When to bring in automation

If the rework drops once rules are written down, the remaining work is often predictable enough to automate with a person approving the risky actions. That is the point where a build makes sense.

I work on this at NxFlowAI (our first step with clients is a 72-hour audit). If you want to see how we explain our own scoring logic in public, the Vibe Checker methodology write-up is open.

Top comments (0)