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…
When a small team finds a process slow, the issue is often not speed but rework. The same order, quote or ticket may be touched repeatedly due to unclear rules. This can be measured before investing in AI, using an exported change log. Most tools can export an activity or change history, which can be shaped into a CSV format with columns like record_id, changed_at, changed_by, field.
Using Python, you can read this CSV file and create a script to count the number of repeat edits per record. The script imports necessary libraries such as csv, defaultdict, datetime, and creates a dictionary to store edits for each record_id. The script then opens the changes.csv file and reads each row using csv.DictReader. It converts the changed_at timestamp to a datetime object and appends a tuple of (timestamp, changed_by, field) to the list of edits for the corresponding record_id in the defaultdict.
After processing all the rows, the script creates a report list to store the results. For each record_id, it sorts the edits, creates a defaultdict to count the number of times each field was edited, and a set to store the unique people who changed the record. It then identifies the repeated fields by checking the count in the fields dictionary. If there are repeated fields, it appends a tuple containing the record_id, total number of edits, number of unique people, and the repeated fields to the report list.
Finally, the script sorts the report list based on the total edits in descending order and prints the top 20 records with their respective details, such as record_id, total edits, number of people involved, and the repeated fields. The output helps in identifying the records with high rework frequency, which can be a key factor in improving the workflow before considering the use of AI.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.