When trying to enable the eikon Data API using Python, my sample code test.py compilation fails stating KeyError in configparser.py with the App Key generated on Eikon. Any idea on how to resolve this?
Hi @donia.augustine,
We don't know what's the structure of your config file which is referenced as variable cfg. If the key that you are trying to use is the appKey, then directly use it in the api call like -
ek.set_app_key('35xxxxxx7b')
Hello @donia.augustine
The Python configparser uses the following syntax for the cfg file:
[section name]key1 = valuekey2= value
Example:
[workspace]app_id = XXXXXX7777BBBBB8888
Usage: cfg['section name']['key'] like the following
import eikon as ekimport configparser as cpcfg = cp.ConfigParser()cfg.read('credential.cfg')ek.set_app_key(cfg['workspace']['app_id'])
Based on your error, your code is cfg['section name'][value] which is not the valid format for the configparser.
#your codeek.set_app_key(cfg['eikon'][{your app key}])