Reads a CSV file with comma or semicolon delimiter and comma or dot
as decimal mark, ignoring unit suffixes (e.g., "0,04 mg/L"). Everything
is read as text first, column names are normalized, and likely numeric
columns are parsed robustly. A conservative safeguard adjusts obviously
out-of-range pH values (e.g., 72 -> 7.2).
Value
A tibble with:
normalized, lowercase column names (spaces to
_, non-alnum removed);numeric columns parsed ignoring unit strings;
dataparsed toDate(triesymdthendmy);pontocoerced to character (if present).
Parsed numeric candidates
c("ph","od","turbidez","dbo","coliformes","p_total","ptotal",
"fosforo_total","temperatura","ec","condutividade","n_nitrato","n_nitrito",
"amonia","nt_total","n_total","ntk","nkjeldahl","nitrogenio_total",
"solidos_totais","solidos_suspensos","tds","conducao","qi","iqa","iet",
"iet_carlson","iet_lamparelli","nsfwqi","vazao")
Examples
if (FALSE) { # \dontrun{
# Minimal example (write a small CSV and read it):
tmp <- tempfile(fileext = ".csv")
writeLines(
c("ponto;data;ph;od;turbidez",
"R1_01;2025-01-20;7,2;6,8;5,1",
"R1_01;21/01/2025;7.1;7.0;4.8 mg/L"),
tmp
)
x <- read_wq(tmp)
str(x)
} # }