read_ini {rconfig} | R Documentation |
Read INI Files
Description
Read INI (.ini
file extension) configuration files.
Usage
read_ini(file, ...)
Arguments
file |
The name and path of the INI configuration file. |
... |
Other arguments passed to the function (currently there is none). |
Details
An INI configuration file consists of sections, each led by a [section]
header,
followed by key/value entries separated by a specific string (=
or :
by default).
By default, section names are case sensitive but keys are not.
Leading and trailing whitespace is removed from keys and values.
Values can be omitted if the parser is configured to allow it,
in which case the key/value delimiter may also be left out.
Values can also span multiple lines, as long as they are indented deeper than the first line of the value.
Blank lines may be treated as parts of multiline values or ignored.
By default, a valid section name can be any string that does not contain \n
or ]
.
Configuration files may include comments, prefixed by specific characters (#
and ;
by default).
Comments may appear on their own on an otherwise empty line, possibly indented.
Value
The configuration value a named list,
each element of the list being a section of the INI file.
Each element (section) containing the key-value pairs from the INI file.
When no value is provided in the file, the value is ""
.
By convention, all values returned by the function are of character type.
R expressions following !expr
are evaluated according to the settings of
the R_RCONFIG_EVAL
environment variable or the option "rconfig.eval"
.
Examples
inifile <- system.file("examples", "example.ini", package = "rconfig")
## not evaluating R expressions
op <- options("rconfig.eval" = FALSE)
ini <- rconfig::read_ini(file = inifile)
str(ini)
## evaluating R expressions
options("rconfig.eval" = TRUE)
ini <- rconfig::read_ini(file = inifile)
str(ini)
# reset options
options(op)