unable to read configfile using Configparser in Databricks

Viewed 1553

I want to read some values as a parameter using configparser in Databricks

i can import configparser module in databricks but unable to read the parameters from configfile its coming up error as KEY ERROR

please check the below screenshot

error sreenshot

config file is

config file

1 Answers

The problem is that your file is located on DBFS (the /FileStore/...) and this is file system isn't understood by configparser that works with "local" file system. To get this working, you need to append the /dbfs prefix to file path: /dbfs/FileStore/....

P.S. it may not work on community edition with DBR 7.x. In this case, just copy this config file before reading using the dbutils.fs.cp, like this :

dbutils.fs.cp("/FileStore/...", "file:///tmp/config.ini")
config.read("/tmp/config.ini")
Related