aidR: Glooko export format

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(aidR)

Overview

path <- system.file("extdata", "glooko_example.zip", package = "aidR")
tmpdir <- file.path(tempdir(), "glooko_example")
unzip(path, exdir = tmpdir)
files <- list.files(tmpdir, recursive = TRUE)

A Glooko export is a folder (possibly zipped) containing CSV files for several data types:

sub("^[^/]+/", "", files) # removes glooko_example/ prefix

A single data type may be split across two or more files, which are then numbered cgm_data_1.csv, cgm_data_2.csv, and so on; aidR reads and concatenates all files matching a given type.

Every file begins with a one-line header, such as Name:Jane Doe,Date Range:2024-01-01 - 2024-03-01, followed by the column headers. Both the one-line header and the column headers are language-specific and vary with the language of the user's Glooko account (example in German):

writeLines(readLines(file.path(tmpdir, files[4]), n = 10))

How aidR detects this format

Because the headers in a Glooko export are language-specific, aidR cannot identify a file from its header names. It relies instead on the structure of the first line (something:something,something:date - date), and then distinguishes between data types by the expected number of columns, which columns are numeric, and, where available, a language-independent keyword such as "(g)" for carbohydrates or "Insulin" for the bolus, basal, and total-insulin files.

Files and the data types they produce

To inspect the files, we parse the export with clean = FALSE, which returns the full information provided by Glooko:

data <- parse_data(id = "1", paths = path, clean = FALSE)

Each entry below describes one raw file and shows an example.

head(data$alarm)
head(data$SMBG)
head(data$carbs_manual)
head(data$cgm)
head(data$basal)
head(data$bolus)
head(data$total_insulin)

Cleaning files

When parse_data is run with clean = TRUE, the cleaned data types are built from the following raw files and attributes:

| Cleaned data type | Used files | Used attributes of clean = FALSE | |-------------------|---------------------------------|-----------------| | cgm | cgm_data_*.csv | data$cgm | | basal | Insulin data/basal_data_*.csv | data$basal | | bolus | Insulin data/bolus_data_*.csv | data$bolus | | carbs | Insulin data/bolus_data_*.csv | data$bolus | | SMBG | bg_data_*.csv | data$SMBG | | total_basal | Insulin data/insulin_data_*.csv | data$total_insulin | | total_bolus | Insulin data/insulin_data_*.csv | data$total_insulin |

Notes



Try the aidR package in your browser

Any scripts or data that you put into this service are public.

aidR documentation built on Oct. 28, 2026, 5:13 p.m.