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. Column names are read without regard to capitalization. A covariate header ending in ! selects carry-forward behavior; otherwise its values are interpolated. The same covariate cannot be declared in both forms.

ADDL/II doses are expanded while reading. Export writes the expanded doses as individual rows. For EVID=4, positive ADDL resets at the base dose time and negative ADDL resets at the earliest expanded dose time. OUT=-99 represents a missing observation, so -99 cannot be preserved as a real observed value.

§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

ID, EVID, and TIME are required. The remaining core columns are 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.