r/CloudandCode • u/yourclouddude Founder | YourCloudDude • 27d ago
Guide [Python] Turn a website checker's CSV into a small incident summary
If you tried the website checker, the next useful step is reading its output.
Here is a local report that counts recorded outcomes. You can also run it using just the sample CSV below.
1. Create health_checks.csv
status,error
200,
404,HTTP_404
,ReadTimeout
200,
302,
2. Save this as summarize.py
import csv
from collections import Counter
counts = Counter()
total = 0
with open("health_checks.csv", newline="", encoding="utf-8") as source:
reader = csv.DictReader(source)
required = {"status", "error"}
if not required.issubset(reader.fieldnames or []):
raise ValueError("CSV needs status and error columns")
for row in reader:
status = (row.get("status") or "").strip()
error = (row.get("error") or "").strip()
label = error or (f"HTTP_{status}" if status else "NO_STATUS")
counts[label] += 1
total += 1
print("Checks:", total)
for label, count in sorted(counts.items()):
print(f"{label}: {count}")
Run python summarize.py in the folder containing the CSV.
Expected output:
Checks: 5
HTTP_200: 2
HTTP_302: 1
HTTP_404: 1
ReadTimeout: 1
3. Interpret it carefully
These are counts of recorded checks. They are not counts of unique incidents, and they are not a measured uptime percentage.
An HTTP 404 can be the correct response for a deliberately missing URL. A 302 means a redirect was returned, not that its destination worked. A timeout tells you this check did not receive the expected response in time; it does not explain the root cause.
The script prefers the recorded error label when present and otherwise labels the HTTP status. A blank status with no error is counted as NO_STATUS rather than silently called successful.
Portfolio extension
Group results by URL and UTC date. Give each URL an expected status, then report mismatches. Preserve the raw CSV so someone can reproduce the summary.
Test a header-only file, a missing error column and a blank status/error row. Decide how malformed rows should be handled before using an imported CSV in a real workflow.
References: csv.DictReader, collections.Counter.