Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Find Where Work Waits: Computing Dwell Time Between Workflow Steps From a Plain CSV Export

Описание и применение

Скрипт на Python читает CSV с записями о статусах и вычисляет медианное время ожидания между соседними этапамиWorkflow. Группировка событий по record_id, сортировка по времени, вычисление переходов и суммарное хранение длин ожиданий позволяют выявитьiest bottleneck.

Задача

A business workflow audit needs to identify where work is stuck, but the only available data is a plain CSV export with record ID, status, and timestamp columns.

Результат

The script outputs median dwell time per workflow step in hours, identifying which handoff or transition has the longest wait. The largest median wait is typically a handoff where someone must notice, decide, or copy something.

Рабочий процесс

  • Read the CSV file with csv.DictReader, grouping rows by record_id into a defaultdict of (timestamp, status) tuples
  • Sort each record's events by timestamp
  • Compute pairwise transition durations between consecutive statuses for each record
  • Aggregate durations into a defaultdict keyed by 'status1 -> status2'
  • Sort aggregated waits by descending median and print each step with its median hours and count

Доказательства

record_id,status,changed_at 101,new,2026-10-01T09:02 101,contacted,2026-10-01T15:40 101,quoted,2026-10-03T11:15 102,new,2026-10-01T10:10 102,contacted,2026-10-02T09:30

Источник

rows = defaultdict(list)

Источник

for (t1, s1), (t2, s2) in zip(events, events[1:]):

Источник

The transition with the largest median wait is usually a handoff: someone has to notice, decide or copy something.

Источник

Two cautions: status changes are only logged when someone updates the record, so long waits can also mean 'forgot to update.' Check a few records by hand.

Источник

This works as a warm-up before a fuller workflow audit. (Disclosure: I co-founded NxFlowAI, whose first audit takes 72 hours.)

Источник

  • Дата записи: 2026-10-27T04:26:24.383Z