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?
Upgrade from Eikon -> Workspace. Learn about programming differences.
For a deeper look into our Eikon Data API, look into:
Overview | Quickstart | Documentation | Downloads | Tutorials | Articles
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?
Hello @donia.augustine
Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?
If so please can you click the 'Accept' text next to the appropriate reply? This will guide all community members who have a similar question.
Thanks,
AHS
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 = value key2= value
Example:
[workspace] app_id = XXXXXX7777BBBBB8888
Usage: cfg['section name']['key'] like the following
import eikon as ek import configparser as cp cfg = 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 code ek.set_app_key(cfg['eikon'][{your app key}])