Skip to contents

Reads a Pinnacle 21 Excel specification, Define-XML, or herald JSON spec file and returns a herald_spec object. Auto-detects format from file extension: .xlsx for P21 Excel, .xml for Define-XML, .json for herald JSON spec.

Usage

read_spec(path)

Arguments

path

Path to the specification file (.xlsx, .xml, or .json).

Value

A herald_spec object.

Examples

# Round-trip: build a spec, write to JSON, read back
if (requireNamespace("jsonlite", quietly = TRUE)) {
  tmp <- tempfile(fileext = ".json")
  on.exit(unlink(tmp), add = TRUE)

  spec <- herald_spec(
    ds_spec  = data.frame(dataset = "DM", label = "Demographics",
                          stringsAsFactors = FALSE),
    var_spec = data.frame(dataset = "DM", variable = c("STUDYID", "USUBJID"),
                          label = c("Study Identifier", "Unique Subject Identifier"),
                          data_type = c("text", "text"),
                          stringsAsFactors = FALSE)
  )
  write_spec(spec, tmp)
  spec2 <- read_spec(tmp)
  spec2
}
#> 
#> ── herald_spec ──
#> 
#> • Dataset: 1
#> • Variables: 2
#> Datasets: "DM"