import csv
from pathlib import Path
from typing import Iterator
def csv_rows(path: str | Path) -> Iterator[dict[str, str]]:
with Path(path).open("r", encoding="utf-8-sig", newline="") as f:
yield from csv.DictReader(f)
for row in csv_rows("export.csv"):
print(row["email"], row["signup_date"])
# uses ~constant memory regardless of file size
# Count by category lazily — only one row in RAM at a time
from collections import Counter
counts = Counter(row["category"] for row in csv_rows("transactions.csv"))
print(counts.most_common(10))
Create a free account and build your private vault. Share publicly whenever you want.