Function read_pmetrics

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

Read a Pmetrics datafile and convert it to a Data object

This function parses a Pmetrics-formatted CSV file and constructs a Data object containing the structured pharmacokinetic/pharmacodynamic data. The function handles various data formats including doses, observations, and covariates.

§Arguments

  • path - The path to the Pmetrics CSV file

§Returns

  • Result<Data, PmetricsError> - A result containing either the parsed Data object or an error

§Example

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

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

§Format details

The Pmetrics format expects columns like ID, TIME, EVID, DOSE, DUR, etc. The function 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

For specific column definitions, see the [Row] struct.