derkork / simplegen

A simple yet powerful general-purpose code generator
Other
9 stars 1 forks source link

Allow additional input formats. #24

Closed derkork closed 3 years ago

derkork commented 4 years ago

It would be nice if we could also use other input formats like CSV or XML or TOML as input in addition to YAML/JSON. These formats could be converted to a fixed data structure on the fly. E.g. for CSV:

Column1;Column2;Column3;
value1;value2;value3;
value4;value5;value6;

and configured like this:

data:
    - includes: myfile.csv
      type: csv
      root: myfile

Could internally yield:

myfile:   #this was specified as "root"
  - Column1: value1
    Column2: value2
    Column3: value3
  - Column1: value4
    Column2: value5
    Column3: value6

Similarly for XML:

<root>
   <foo bar="baz">
     <entries>
         <lorem ipsum="dolor">sit amet</lorem>
         <lorem ipsum="dolor">sit amet 2</lorem>
     </entries>
     <remarks/>
  </foo>
</root>
root:
   foo:
     "@bar": baz
      entries:
         - lorem:
               "@ipsum" : dolor
               __text: sit amet
        - lorem:
               "@ipsum" : dolor
               __text: sit amet 2
       remarks: 
            __text: ""

Or TOML:

[foo]
bar="baz"
foo:
  bar: "baz"
derkork commented 3 years ago

This is now possible in 2.1.0.