% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/f_io_utilities.R
\name{readKeyValueFile}
\alias{readKeyValueFile}
\title{Read a key-value file (KEY=VALUE) into a named list}
\usage{
readKeyValueFile(
  filePath,
  ...,
  inferTypes = TRUE,
  duplicateKeys = c("error", "last", "first"),
  safeKeyCheck = FALSE
)
}
\arguments{
\item{filePath}{Path to the key-value file.}

\item{...}{Currently unused.}

\item{inferTypes}{Logical; if \code{TRUE}, attempts to convert values to
logical/integer/numeric and \code{NA}. If \code{FALSE}, returns character values.}

\item{duplicateKeys}{How to handle duplicate keys: \code{"error"} (default),
\code{"last"} (keep last occurrence), or \code{"first"} (keep first occurrence).}

\item{safeKeyCheck}{Logical; if \code{TRUE}, checks that keys only contain
allowed characters. Set to \code{FALSE} (default) to allow arbitrary keys, but be aware that
this may lead to issues when reading the file back, as keys with special characters
may not be parsed correctly.}
}
\value{
A named list with parsed values.
}
\description{
Reads a human-editable key-value file in a widely used format
(INI/.env-like): \code{KEY=VALUE}. Blank lines are ignored.
Full-line comments starting with \code{#} or \code{;} are ignored.
Inline comments are supported for unquoted values when preceded by whitespace,
e.g., \code{KEY=123 # comment}.
}
\details{
Values can be quoted with double quotes. Escape sequences \code{\\n},
\code{\\r}, \code{\\t}, \code{\\\\}, and \code{\"} are supported.

UTF-8 handling: The file is read as UTF-8 and all character values are
normalized to UTF-8 via \code{enc2utf8()}.
}
\examples{
\dontrun{
keyValueList <- list(
    STUDY_NAME = "Trial A",
    MAX_PATIENTS = 150L,
    THRESHOLD = 0.075,
    NOTES = "First phase\nSecond phase"
)
filePath <- tempfile(fileext = ".txt")
writeKeyValueFile(
    keyValueList = keyValueList,
    filePath = filePath,
    writeHeader = TRUE,
    sortKeys = TRUE,
    overwrite = TRUE
)
readKeyValueFile(filePath)
}

}
\keyword{internal}
