---
title: "I Built a CGM Data Reader"
description: "Built a CGM data analysis tool with Python to visualize Freestyle Libre 3 glucose data alongside nutrition, workouts, and sleep for endurance cycling."
date: 2025-01-02
updated: 2026-05-04
author: "Philipp D. Dubach"
categories:
  - "Tech"
keywords:
  - "CGM data analysis Python"
  - "Freestyle Libre 3 data export"
  - "continuous glucose monitor dashboard"
  - "CGM for endurance athletes"
  - "glucose tracking Python visualization"
type: "Project"
canonical_url: "https://philippdubach.com/posts/i-built-a-cgm-data-reader/"
source_url: "https://philippdubach.com/posts/i-built-a-cgm-data-reader/index.md"
content_signal: search=yes, ai-input=yes, ai-train=yes
---

# I Built a CGM Data Reader

*Philipp D. Dubach · Published January 2, 2025 · Updated May 4, 2026*


## Key Takeaways

- Abbott's LibreLink app has a 2.9/5.0 rating from 3,250 reviews, so I built a Python dashboard that merges Libre 3 glucose data with nutrition, workout, and sleep data from five sources
- The dashboard overlays workout traces, meal macros, and sleep phases onto continuous glucose readings, letting you spot correlations the stock app cannot surface
- Key metrics for endurance athletes include time-in-range, coefficient of variation, and pattern analysis around meals and training loads


---

>_If you're reading this, you might also be interested in: [Modeling Glycemic Response with XGBoost](/posts/modeling-glycemic-response-with-xgboost/)_

Last year I put a Continuous Glucose Monitor (CGM) sensor, specifically the [Abbott Freestyle Libre 3](https://www.freestyle.abbott), on my left arm. Why? I wanted to optimize my nutrition for endurance cycling competitions. Where I live, the sensor is easy to get—without any medical prescription—and even easier to use. Unfortunately, Abbott's [FreeStyle LibreLink](https://apps.apple.com/us/app/freestyle-librelink-us/id1325992472) app is less than optimal (3,250 other people with an average rating of 2.9/5.0 seem to agree). In their defense, the web app LibreView does offer some nice reports which can be generated as PDFs—not very dynamic, but still something! What I had in mind was more in the fashion of the [Ultrahuman M1 dashboard](https://ultrahuman.com/m1). Unfortunately, I wasn't allowed to use my Libre sensor (EU firmware) with their app (yes, I spoke to customer service).

At that point, I wasn't left with much enthusiasm, only a coin-sized sensor in my arm. The LibreView website fortunately lets you download most of your (own) data in a CSV report (_there is also a [reverse engineered API](https://github.com/FokkeZB/libreview-unofficial)_), which is nice. So that's what I did: download the data, `pd.read_csv()` it into my notebook, calculate summary statistics, and plot the values.
![Visualized CGM Datapoints](https://static.philippdubach.com/cdn-cgi/image/width=1600,quality=85,format=auto/libre-measurements.jpg)

After some interpolation, I now had the same view as the LibreLink app (which I had rejected earlier) provided. Yet, this setup allowed me to do further analysis and visualizations by adding other datapoints (workouts, sleep, nutrition) I was also collecting at that time:

- Blood sugar from [LibreView](https://www.libreview.com/): Measurement timestamps + glucose values
- Nutrition from [MacroFactor](https://macrofactorapp.com/): Meal timestamps + macronutrients (carbs, protein, and fat)
- Sleep data from [Sleep Cycle](https://sleepcycle.com/): Sleep start timestamp + time in bed + time asleep (+ sleep quality, which is a proprietary measure calculated by the app)
- Cardio workouts from [Garmin](https://connect.garmin.com/): Workout start timestamp + workout duration
- Strength workouts from [Hevy](https://www.hevyapp.com/): Workout start timestamp + workout duration

![Final Dashboard](https://static.philippdubach.com/cdn-cgi/image/width=1600,quality=85,format=auto/cgm-dashboard.jpg)

After structuring those datapoints in a dataframe and normalizing timestamps, I was able to quickly highlight sleep (blue boxes with callouts for time in bed, time asleep, and sleep quality) and workouts (red traces on glucose measurements for strength workouts, green traces for cardio workouts) by plotting highlighted traces on top of the historic glucose trail for a set period. Furthermore, I was able to add annotations for nutrition events with the respective macronutrients.

*Related: [Modeling Glycemic Response with XGBoost](https://philippdubach.com/posts/modeling-glycemic-response-with-xgboost/)*

I asked Claude to create some sample data and streamline the functions to reduce dependencies on the specific data sources I used. The resulting notebook is a comprehensive CGM data analysis tool that loads and processes glucose readings alongside lifestyle data (nutrition, workouts, and sleep), then creates an integrated dashboard for visualization. The code handles data preprocessing including interpolation of missing glucose values, timeline synchronization across different data sources, and statistical analysis with key metrics like time-in-range and coefficient of variation. The main output is a day-by-day dashboard that overlays workout periods, nutrition events, and sleep phases onto continuous glucose monitoring data, enabling users to identify patterns and correlations between lifestyle factors and blood sugar responses. 

You can find the complete [notebook](https://github.com/philippdubach/glucose-tracker/blob/fd5992961cfb4630dad439c782430190937414a3/notebooks/data_exploration.ipynb) as well as the sample data in my [GitHub repository](https://github.com/philippdubach/glucose-tracker/).



---

## Frequently Asked Questions


### How do I export Freestyle Libre 3 glucose data for custom analysis?

You cannot export data directly from the LibreLink app, but LibreView (Abbott's web platform) lets you download your glucose history as a CSV file. Log in at libreview.com, navigate to your glucose history, and select "Download Glucose Data." From there you can load the CSV into Python with pandas for further analysis.


### Can I combine CGM data with nutrition and workout data in Python?

Yes. By normalizing timestamps across data sources, you can merge glucose readings from LibreView with nutrition data from MacroFactor, sleep data from Sleep Cycle, and workout data from Garmin or Hevy into a single pandas DataFrame. This lets you overlay workout periods, meal events, and sleep phases onto your glucose trace to spot correlations.


### What glucose metrics are useful for endurance athletes?

Key metrics include time-in-range (the percentage of time glucose stays within a target zone), coefficient of variation (a measure of glycemic variability), and pattern analysis around meals and workouts. These help athletes understand how fueling strategies affect blood sugar during training and recovery.


### Is a CGM useful for non-diabetic athletes?

For endurance athletes, a CGM can reveal how specific foods, training loads, and sleep quality affect blood sugar patterns. The Abbott Freestyle Libre 3 is available without a prescription in many countries, making it accessible for athletes who want to fine-tune their nutrition strategy for competition.


### What are the limitations of Abbott's LibreLink app for data analysis?

The LibreLink app provides basic glucose readings but lacks the ability to integrate data from other sources like nutrition trackers, sleep apps, or workout logs. LibreView offers downloadable PDF reports, but these are static and not suitable for dynamic analysis. Building a custom dashboard with Python gives you far more flexibility to correlate glucose with lifestyle factors.



---

Canonical: https://philippdubach.com/posts/i-built-a-cgm-data-reader/
Content-Signal: search=yes, ai-input=yes, ai-train=yes
This file is the canonical machine-readable variant of https://philippdubach.com/posts/i-built-a-cgm-data-reader/. Author: Philipp D. Dubach (https://philippdubach.com/).
