ConfigParser is a Python module for reading and writing configuration files that have a structure similar to those of INI files in Microsoft Windows.
Questions tagged [configparser]
683 questions
-1
votes
2 answers
How can i add to top of a txtfile in python?
I have a sql query txt file i would like to append to (at the top).
The items i want to add are from this yml file:
data:
START_DT: '202001'
END_DT: '202104'
i call this yml file in my python script using:
import yaml
with…

Maths12
- 852
- 3
- 17
- 31
-1
votes
1 answer
Hi need to generate some valid date formate
I have some date in a .ini "yyyymmdd" format.
my .ini files details:
[global]
date_with_interval = 20210311:3, 20200228:4
In this above variable, I have two values with colon-separated 1st one is the date and 2nd interval
so based on the interval…

abhi spdy
- 25
- 5
-1
votes
1 answer
ConfigParser has no attribute
config.cfg
[database]
SQLALCHEMY_DATABASE_URI = 'sqlite:///app.db'
config.py
# -*- encoding: utf-8 -*-
import os
from os import makedirs
from configparser import ConfigParser
config = ConfigParser()
if os.path.isfile(os.path.join("server",…

Matthew M. Dean
- 11
- 3
-1
votes
2 answers
Python configparser Append
Is there a way to append the values to config file using configparser?
[DEFAULT]
ServerAliveInterval = 45
Compression = yes
CompressionLevel = 9
ForwardX11 = yes
message = first run, second run, third run
I want to append message value like shown…

Eager2Learn
- 31
- 3
-1
votes
1 answer
How do I stop repeated unwanted values when looping ConfigParser in Python?
I'm trying to use configParser to upload .ini files. Everything is working well, until I get to a nested loop. I'm trying to find key values in each file, then in each section in that file, and print out the key-pair values.
for i in iniFiles:
…
-1
votes
1 answer
Python - configuration file
I have code:
import matplotlib.pyplot as plt
from configparser import ConfigParser
cfg = ConfigParser()
cfg.read('file.cfg')
plt.plot([1, 10],[2, 2], color_4, ls = "dashed")
plt.xlim(1,10)
plt.ylim(1,4)
plt.savefig('image.pdf')
and I would…

Arrara
- 173
- 1
- 10
-1
votes
2 answers
How to read and write INI files as a section using python configparser?
I have Db.ini files and i want to read and write the file as a section using python's configparser.Can anyone explain me how to read and write the config file as a section using configparser?
Db.ini
[mysql]
host = localhost
user = user7
passwd =…

Saravanan Selvam
- 109
- 1
- 2
- 12
-1
votes
1 answer
How can I read in database credentials from a text file?
How can I read in database credentials from a text file in my Python script? When Grafana searches for the target, it should go to the text file and get the DB credentials and execute it.
import cx_Oracle
import pprint
con = cx_oracle.connect(user=…

rohit rocckz
- 19
- 1
- 6
-1
votes
1 answer
Parse through Cisco Config
I been trying to write a Python script to go through 20 some cisco configurations.
So Far, I got a script to work on one config and it parsed out the interfaces that do not have 802.1x authentication* interface commands.
I'm having trouble…

BaoJia
- 3
- 3
-1
votes
1 answer
Dont show me again checkbox
I want a window with "don't show me again" (a toplevel-window). If this box get's checked, I don't want it showing me this window another time.
import configparser
from tkinter import *
config = configparser.RawConfigParser() #my ini…

stackrangerflow
- 51
- 1
- 1
- 6
-1
votes
1 answer
Config file error
I have mada a config file for my python program.. The config file contains my variable which uses the 'i2cset' module.. It is as follows:
This is my config file called'try.ini'
[new]
a = ('i2cset', '-y', '0', '0x20', '0x14', '0x01')
I read it…

Goldengirl
- 957
- 4
- 10
- 30
-1
votes
4 answers
How to make Python Configuration File from user input, and insert runs?
I've got a bunch of Python webdriver runs that I've converted from Selenium IDE. These runs have 1 or 2 settings that I would like to be able to change using a configuration file that would be created by running a script that collects user input…

edszr
- 63
- 2
- 10
-1
votes
2 answers
Best way to manage default and cutomizable configuraton in Python
Good Morning,
I'm re-factoring a script which will have (literally) dozens to hundreds of user configurable parameters.
The first step is, of course, to implement a GUI with check-boxes for which parameters to turn on and off, and a few entry…

RightmireM
- 2,381
- 2
- 24
- 42
-1
votes
1 answer
List returned by SafeConfigParser is [''], but shows a len() of 1
I have a config file something like:
[Expected Response]
GlobalResponse:
UniqueResponse:
1221
What I'm trying to do is, if GlobalResponse is empty, then we rely on UniqueResponse being set.
subConfigParser =…

MrDuk
- 16,578
- 18
- 74
- 133
-2
votes
1 answer
How to do if statement and assignment in configparser config file?
I want to use if statement and variable assignment in my config file. I have tried but it seems impossible. Right now the "begin" value is read in and the application runs it using python system call. So it will be system(
if…

user2719735
- 97
- 2
- 10