GlucoseIQ
API Reference@glucoseiq/core

Ingestion

Mapped header-row delimited data parsing.

parseGlucoseCSV

Import: @glucoseiq/core

parseGlucoseCSV(text: string, options: CSVParseOptions): GlucoseReading[]

Parses CSV text into glucose readings.

Empty and blank-only documents return an empty array. A header-only document also returns an empty array after validating both mapped columns. Quoted fields and doubled quotes are supported, but physical newlines inside a quoted field are not.

Returns: Parsed readings (rows with an unparseable value or timestamp are skipped)

Throws: If the delimiter is invalid

Throws: If a named column is not present in the header

import { parseGlucoseCSV } from '@glucoseiq/core'

const csv: string = [
  'Timestamp (YYYY-MM-DDThh:mm:ss),Glucose Value (mg/dL)',
  '2024-01-01T08:00:00Z,120',
].join('\n')
const readings = parseGlucoseCSV(csv, {
  timestampColumn: 'Timestamp (YYYY-MM-DDThh:mm:ss)',
  valueColumn: 'Glucose Value (mg/dL)',
})
ParameterDescription
textThe CSV document
optionsColumn names, unit, and delimiter

On this page