> "var1=value1", "A=value3" is almost pure R code.
> Is it possible to use this feature to solve the problem?



Along the same lines: you may write a short script that converts the ini
file into R code that can be sourced.

>From your example, you can generate  the  following R code:

Section1 <- list()
Section1['var1'] <- value1
Section1['var2'] <- value2
Section2 <- list()
Section2['A'] <- value3
Section2['B'] <- value4


with the following awk script (using awk -F'=' -f conv.awk example.ini >
example.R)

### conv.awk
$1 ~ /\[/ { gsub(/[\[\]]/,""); # remove the brackets
       listname = $1;
       print $1 " <- list()";
       next }
{ print listname "['" $1 "'] <- " $2 }

(I know, it looks cryptic... so I am shooting myself in the foot after
claiming that awk scripts are typically quite readable ;-)

-- 
Christophe Pallier (http://www.pallier.org)

        [[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to