# Second pass: more focused analysis import csv from datetime import datetime, timedelta def load_cgm(filepath): data = {} with open(filepath) as f: reader = csv.DictReader(f) for row in reader: dt = datetime.strptime(row['Date/Time'], '%Y-%m-%d %H:%M:%S') bg = float(row['Blood Glucose (mg/dL)']) data[dt] = bg return data cgm_mar6 = load_cgm('/home/ben/ava/ben/Blood-Glucose-2026-03-06-2026-03-06.csv') cgm_mar7_14 = load_cgm('/home/ben/downloads/Blood Glucose-2026-03-07-2026-03-14.csv') cgm = {**cgm_mar6, **cgm_mar7_14} # Big spike analysis - what meals caused spikes > 140? print("=" * 60) print("BIGGEST SPIKE MEALS (peak > 140)") print("=" * 60) # These are from the analysis above, let me compile the worst offenders spikes = [ ("Mar 7 11:34", "Pancakes with sausage and syrup", 147, 206, 59), ("Mar 11 17:55", "Beef stir fry with vegetables and rice", 104, 188, 84), ("Mar 7 09:48", "Whole wheat breakfast burritos", 126, 166, 40), ("Mar 6 19:15", "Vanilla ice cream with cherries and chocolate", 123, 163, 40), ("Mar 6 16:23", "Croissant, chicken broth and poached eggs", 93, 151, 58), ("Mar 7 18:32", "Ground beef, roasted sweet potato and avocado", 128, 154, 26), ("Mar 9 17:15-18:24", "Protein bar + figs + spaghetti (stacked)", 105, 155, 50), ("Mar 12 11:15", "Figs", 116, 147, 31), ("Mar 10 08:40", "Scrambled eggs on toast with pastry", 121, 146, 25), ("Mar 8 13:09", "Tea with honey, bread roll, salad, cake bites", 117, 146, 29), ] print(f"\n{'When':<22} {'Pre':>4} {'Peak':>5} {'Δ':>4} Food") for when, food, pre, peak, delta in sorted(spikes, key=lambda x: -x[3]): flag = "🔴" if peak > 160 else "🟡" print(f" {flag} {when:<20} {pre:>4} {peak:>5} +{delta:<3} {food}") # Best days analysis print(f"\n{'=' * 60}") print("BEST vs WORST DAYS") print("=" * 60) print(""" BEST: Mar 14 — mean 109, max 115, TIR 100% Ate: coffee+pastry, eggs, PB&J rice cake, salmon toast, tacos, cobbler 6 meals across 10.6h window, 13.6h overnight fast Pattern: small frequent meals, protein-heavy, moderate carbs spread out BEST: Mar 9 — mean 112, max 155, TIR 97% 22h fast day. Z2 ride + kettlebells. Late eating window (13:31-18:24) Pattern: long fast + exercise = low baseline, single spike from stacked dinner BEST: Mar 6 — mean 112, max 163, TIR 94% 70h fast break. ~3h eating window (16:23-19:15) Pattern: very tight window, but fast-break carbs (croissant, ice cream) caused spikes WORST: Mar 7 — mean 136, max 206, TIR 69% All-day grazing (9:48-18:32, 8.7h window) Pancakes+syrup at 11:34 → 206 spike (highest recorded) Pattern: early carb-heavy breakfast + continuous eating, never recovered WORST: Mar 11 — mean 118, max 188, TIR 93% Long eating window (8:25-20:10, 11.8h) Beef stir fry with rice at 17:55 → 188 spike (+84!!!) Pattern: rice was the clear culprit. Morning quiche was fine. """) # Food-specific observations print(f"{'=' * 60}") print("FOOD-SPECIFIC PATTERNS") print("=" * 60) print(""" SPIKE FOODS (consistently cause >140): • Pancakes + syrup: +59 to 206 (worst recorded) • Rice (stir fry): +84 to 188 (surprising magnitude) • Ice cream: +40 to 163 • Croissant (fasted): +58 to 151 • Figs (alone): +31 to 147 • Toast/pastry (breakfast): +25-29 to 146 SAFE FOODS (peak stays under 140): • Steak + vegetables: virtually no spike (Mar 8 dinner: peak 111) • Greek yogurt + protein powder: +2 to +14 • Eggs (any style): minimal spike unless paired with carbs • Beef gyro salad + pita: +19 to 129 (pita okay in context of protein) • Shrimp salad: +27 to 136 • Ham & cheese tortillas: +24 to 123 • Baked chicken + sides: +13 to 121 (even with mac&cheese/cornbread!) • Decaf with heavy cream: +1 CONTEXT-DEPENDENT: • Bread/toast: fine with protein (salmon toast: minimal spike), bad alone or with carbs (breakfast burrito: +40) • Pita: fine with protein-heavy meal (gyro salad: +19) • Pasta/spaghetti: moderate spike when eaten late after fasting (+36-41) but RICE is worse than pasta for you """) # Fasting window analysis print(f"{'=' * 60}") print("FASTING WINDOW ANALYSIS") print("=" * 60) print(""" Overnight fast → next-day fasting glucose (4-7am avg): 10.8h → 116 (short fast, moderate glucose) 11.8h → 111 13.6h → 114 14.3h → 118 14.6h → 122 (Mar 7, worst day overall) 18.6h → 119 18.7h → 111 19.4h → 114 NO clear linear relationship between fast length and fasting glucose. Range is tight: 111-122 regardless of 11-19h fast. This is consistent with hepatic insulin resistance — liver dumps glucose regardless of fast duration. The dawn phenomenon dominates. What DOES correlate with better days: 1. Eating window < 6h: mean 112-113 (Mar 6, 8, 9, 13) 2. Eating window > 8h: mean 118-136 (Mar 7, 10, 11, 12) Exception: Mar 14 had 10.6h window but mean 109 — but that day had 6 small meals, all protein-heavy, no major carb bombs. Key insight: it's not WHEN you eat, it's WHAT you eat. Tight window helps only because it constrains total carb exposure. Mar 14 proves you can eat all day and stay flat if the food is right. """)