Sub topic 8
Clean up the log at the end of the week
This chapter assumes you have a seven-day log in the CSV format from earlier chapters: one row per activity with date, start, end, category, activity, and energy. You should also be comfortable reading a simple table. Cleaning comes before totals, because every total inherits the mistakes in the log.
Why cleaning comes first
A raw log has three kinds of defects. Each one skews the hours you calculate later.
- Gaps: stretches of the day with no row, such as the 20 minutes between two meetings.
- Overlaps: two rows that claim the same minutes, often because you logged an entry from memory and rounded it.
- Inconsistent categories: the same kind of work filed under different names, such as
emailon Monday andcommunicationon Wednesday.
Clean the log in one sitting, ideally on the last evening or the next morning. Memory of the week fades quickly, and the fixes depend on it.
Work on a copy
Save the original as time_log_raw.csv and edit a copy named time_log.csv. If a fix turns out to be wrong, you can go back. Never overwrite the raw file.
Fix gaps
A gap is any time between the end of one row and the start of the next, within the hours you chose to track. Look at each one and decide what it was.
- If you remember it, add a row with the right category.
- If it was a short transition (under about 10 minutes), extend the previous entry or leave it. Do not invent detail.
- If you cannot remember, add a row with the category
unknown.
Keeping unknown visible is more honest than guessing. If it ends up above 10% of your tracked time, say so when you interpret the results.
Fix overlaps
An overlap happens when a row starts before the previous row ends. Here is an example:
date,start,end,category,activity,energy
2026-03-03,09:00,10:30,deep_work,Draft quarterly report,4
2026-03-03,10:15,10:45,communication,Email and chat,3The two rows share 10:15 to 10:30. Decide which activity actually happened in that window and trim the other. Overlaps can also be real, such as answering chat during a meeting. If so, pick one rule and use it all week, for example "log the main activity only."
Make categories consistent
List every distinct category in the file and compare it with your planned set. Merge variants into one name and move stray labels into the nearest category. The script below flags problems so you do not have to find them by eye. It reports unknown categories, overlaps, and gaps of more than 10 minutes.
import csv
from datetime import datetime
ALLOWED = {"deep_work", "communication", "meetings", "admin", "unknown"}
GAP_LIMIT_MIN = 10
rows = []
with open("time_log.csv", newline="") as f:
for row in csv.DictReader(f):
row["_start"] = datetime.strptime(f"{row['date']} {row['start']}", "%Y-%m-%d %H:%M")
row["_end"] = datetime.strptime(f"{row['date']} {row['end']}", "%Y-%m-%d %H:%M")
rows.append(row)
rows.sort(key=lambda r: r["_start"])
for r in rows:
if r["category"] not in ALLOWED:
print(f"Unknown category '{r['category']}' on {r['date']} at {r['start']}")
for prev, cur in zip(rows, rows[1:]):
if prev["date"] != cur["date"]:
continue
minutes = (cur["_start"] - prev["_end"]).total_seconds() / 60
if minutes < 0:
print(f"Overlap of {-minutes:.0f} min on {cur['date']} at {cur['start']}")
elif minutes > GAP_LIMIT_MIN:
print(f"Gap of {minutes:.0f} min on {cur['date']} after {prev['end']}")Edit the CSV, then run the script again. Repeat until it prints nothing.
The cleaning loop
Common errors
- Editing the raw file and losing the original.
- Filling every gap with a plausible guess instead of using
unknown. - Changing category names halfway through, which splits one category into two.
- Entries that cross midnight. The script assumes each entry stays within one day, so split such rows at 00:00.
Exercise
Your log has a row ending at 14:00 and the next row starting at 14:35, and you cannot remember what you did in between. What should you do, and why?
Show answer
Add a 35-minute row with the category unknown. The gap is longer than a short transition, so leaving it would understate your tracked time, and guessing a category would add false data. Keeping unknown visible shows how reliable the log is.