[R] Parsing configuration files
Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Mon May 18 14:19:40 CEST 2009
Uwe Ligges wrote:
> Marie Sivertsen wrote:
>> Dear list,
>> Is there any functionality in R that would allow me to parse config
> Which kind of config files? R has read.dcf, for example.
indeed, there are quite a number of more or less unambiguously specified
configuration file formats.
for the lack of an existing solution (or, more likely, due to my
ignorance) i've crufted together a trivial script that parses simple
ini-like config files, with square-bracketed section headers, like this:
bar = BAR
foo = ...
you just source the script, specify the config file, and get a nested
list of config parameters, e.g.
config = rconfig('somefile.cfg')
the functionality is rudimentary and not fool-proof, no string-to-number
parsing, no comment skipping, etc. i'm not really suggesting it as a
solution to your (underspecified) problem, feel free to modify/extend it
to match your needs.
More information about the R-help