I'm using configparser in order to read and modify automatically a file conf named 'streamer.conf'. I'm doing this :
import configparser
config = configparser.ConfigParser()
config.read('C:/Users/../Desktop/streamer.conf')
And then it breaks apart with this Error message :
MissingSectionHeaderError: File contains no section headers.
file: 'C:/Users/../Desktop/streamer.conf', line: 1
u'input{\n'
What might be wrong? Any help appreciated.
just specify right encoding
config.read(config_file_path, encoding='utf-8-sig')
As mentioned in other answers the config file needs to be INI format, but the actual error you're seeing is due to the fact that the requested config file is missing any section headers (as mentioned in the error message) - these are names enclosed in square brackets which provide a header for a section of the INI file. The default header is [DEFAULT] e.g.
[DEFAULT]
config_item1='something'
config_item2=2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With