Skip to main content

read_pmetrics

Function read_pmetrics 

pub fn read_pmetrics(path: impl Into<String>) -> Result<Data, DataError>
Expand description

Read a Pmetrics CSV file into Data.

Use read_pmetrics when the source file already follows the usual Pmetrics column convention instead of mapping the file into DataRow values yourself.

The parser normalizes header names to lowercase, preserves INPUT and OUTEQ as public labels, expands ADDL dosing rows through the shared row ingestion path, and groups rows into occasions using EVID=4.

All columns not claimed by the core Pmetrics schema are treated as covariates.

§Arguments

  • path - Path to the Pmetrics CSV file

§Returns

A parsed Data object or a [DataError] if the file cannot be read or a required row field is missing.

§Example

use pharmsol::prelude::data::read_pmetrics;

let data = read_pmetrics("path/to/pmetrics_data.csv").unwrap();
println!("Number of subjects: {}", data.subjects().len());

§Expected columns

The canonical columns are ID, TIME, EVID, DOSE, DUR, ADDL, II, INPUT, OUT, OUTEQ, CENS, and optional C0..C3 error coefficients.

All other numeric columns are treated as covariates.

§Parsing behavior

The parser will:

  • Convert all headers to lowercase for case-insensitivity
  • Group rows by subject ID
  • Create occasions based on EVID=4 events
  • Parse covariates and create appropriate interpolations
  • Handle additional doses via ADDL and II fields
  • Preserve raw INPUT and OUTEQ labels as strings until model resolution
  • Treat OUT=-99 as a missing observation value, matching the common Pmetrics convention

For specific column definitions, see the Row struct.