Skip to contents

Parses files conforming to the BADC-CSV 1.0 convention used by the UK Centre for Environmental Data Analysis (CEDA). These files have a variable number of header rows describing each column by number, followed by a column-index row (`1,2,3,...,N`) and then the data.

Usage

read_ceda_csv(fname, drop_flags = TRUE)

Arguments

fname

Path to the BADC-CSV file.

drop_flags

Logical (default `TRUE`). Drop flag columns whose names begin with `"Flag"` or `"FLAG"`.

Value

A `data.table` with a `TIMESTAMP` column (POSIXct, UTC) and one numeric column per measurement variable.

Details

Column names are taken from `short_name` metadata rows where available, falling back to `long_name`. The first column is always renamed `"TIMESTAMP"` and parsed to POSIXct (UTC). Flag columns (names beginning with `"Flag"` or `"FLAG"`) are dropped by default. Redundant packed datetime columns in `YYYYMMDDHHMM` format are dropped automatically. Missing-value sentinels (`-9999`, empty fields) are converted to `NA`.

Examples

if (FALSE) { # \dontrun{
dt <- read_ceda_csv(pkg_extdata("UK-AMO/historical/ceda/AU_MetData_2023.csv"))
dt <- read_ceda_csv(pkg_extdata("UK-BUC/historical/ceda/BushCabin_2024.csv"))
} # }