PyPSA / powerplantmatching

Set of tools to combine multiple power plant databases
https://powerplantmatching.readthedocs.io/en/latest/
GNU General Public License v3.0
152 stars 52 forks source link

Issue with reading config #162

Closed eltonelero closed 1 month ago

eltonelero commented 4 months ago

In core.py the config is read by

with open(base_config) as f:
        config = yaml.load(f, Loader=yaml.FullLoader)
    if exists(custom_config):
        with open(custom_config) as f:
            config.update(yaml.load(f, Loader=yaml.FullLoader))

This can lead to encoding issues on some machines. Leading to an error like this:

yaml.reader.ReaderError: unacceptable character #x009f: special characters are not allowed

I would suggest changing it to

with open(base_config, encoding='utf8') as f:
        config = yaml.load(f, Loader=yaml.FullLoader)
    if exists(custom_config):
        with open(custom_config, encoding='utf8') as f:
            config.update(yaml.load(f, Loader=yaml.FullLoader))

Worked for me. Cheers.