I am using ConfigParser to edit my configuration file, but while updating the value in config file it ends up with removing all comments and converts all option values to lowercase from camelcase.
My Initial config file:
[Recording]
Record Video = Yes
Type = mp4
# You can use [low/medium/high] all lowercase
Quality = medium
# The name of recording file.
Name = Recording
My python script
import configparser
CFG_FILENAME = 'config.txt'
cfg = configparser.RawConfigParser()
cfg.read(str(CFG_FILENAME))
cfgfile = open(str(CFG_FILENAME), 'w')
cfg.set('Recording', 'Record Video','No')
cfg.write(cfgfile)
cfgfile.close()
The Output file
[Recording]
record video = No
type = mp4
quality = medium
name = Recording
Please help me with this. Thanks in advance.