Reputation: 11
I have a scala config file created with the library pureconfig. I would like to write a wrapper in python to read and write this configfile (to give a better access to non scala users). Is the easiest way to parse the whole schema ?
My config file looks like:
tables = [
{
name = TABLE_1
partition_strategy = "none"
partitions = [
{
path = [
"/shared/fall/raw/TABLE_1_2015.csv"
]
}
]
}
{
name = TABLE_2
partition_strategy = "none"
partitions = [
{
path = [
"/shared/fall/raw_data/TABLE_2_2015.csv"
]
}
]
}
{
name = TABLE_3
partition_strategy = "year"
partition_column = "FLX_DIS_DTD"
partitions = [
{
year = 2014
path = [
"/shared/fall/raw/2014_2016/PRODUCT/TABLE_3*2014.CSV",
"/shared/fall/raw/2014_2016/PRODUCT/TABLE_3*2015.CSV",
]
},
{
year = 2016
path = [
"/shared/fall/raw/2014_2016/PRODUCT/TABLE_3*2016.CSV",
"/shared/fall/raw/2014_2016/PRODUCT/TABLE_3*2017.CSV",
]
}
]
}
]
Upvotes: 1
Views: 930
Reputation: 5236
According to @mjjaniec: This syntax appears to be HOCON. You can use a Hocon parser like PyHocon
This package also provides a conversion tool to convert from HOCON to the JSON, .properties and YAML formats.
usage: pyhocon [-h] [-i INPUT] [-o OUTPUT] [-f FORMAT] [-n INDENT] [-v]
optional arguments:
-h, --help show this help message and exit
-i INPUT, --input INPUT input file
-o OUTPUT, --output OUTPUT output file
-c, --compact compact format
-f FORMAT, --format FORMAT output format: json, properties, yaml or hocon
-n INDENT, --indent INDENT indentation step (default is 2)
-v, --verbosity increase output verbosity
Upvotes: 0