Questions tagged [configparser]

ConfigParser is a Python module for reading and writing configuration files that have a structure similar to those of INI files in Microsoft Windows.

683 questions
4
votes
1 answer

ConfigParser getting value from INI file with section and subsection as shown below

I have a following type of INI file [section1][subsection1] port=989 [section1][subsection2] somethign=somethign I am using ConfigParser of Python to parse the INI file but I am not able to figure it out on how to get the data from the above kinda…
bana
  • 397
  • 1
  • 5
  • 16
4
votes
1 answer

Modify path of execution of a python script running as a windows service

I have a Python application that uses ConfigParser.ConfigParser() to access a configuration file. I have created a windows service of the Python application using py2exe. The problem that I have is that the service can only find the configuration…
4
votes
2 answers

How to read config file from module and from main file?

I've a problem with loading and reading my config file. When I running the imptest.py file then Python read configfile.cfg and I get following output: D:\tmp\test\dir1>python imptest.py Section1 Section2 Section3 But when I running the mainfile.py…
Szymon
  • 633
  • 1
  • 8
  • 28
3
votes
1 answer

Python error : ConfigParser.NoSectionError: No section:

I'm new to Python and would like to read a config file using the ConfigParser module. Here is my config file: [Server] server_name= localhost And here is my code: #!/usr/bin/env python import ConfigParser config =…
Will Dowling
  • 33
  • 1
  • 1
  • 3
3
votes
2 answers

Airflow issue with pathlib / configparser - 'PosixPath' object is not iterable

I am trying to containerize my airflow setup. I've been tasked to keep the environment the same, just move it into a docker container. We currently have Airflow and all our dependencies installed within a anaconda environment. So what I've done is…
wymangr
  • 189
  • 3
  • 16
3
votes
0 answers

TypeError with open function with configparser

I have this problem with open() function in python. It returns me this: Traceback (most recent call last): File "c:\Users\Gianmarco\Documents\Progetto SARHIS\main.py", line 32, in Write_N_Load() File…
3
votes
2 answers

How to read indentated sections with python configparser

I try to read the following config file with python configparser: # test.conf [section] a = 0.3 [subsection] b = 123 # main.py import configparser conf = configparser.ConfigParser() conf.read("./test.conf") a =…
Käseknacker
  • 221
  • 2
  • 15
3
votes
2 answers

Can I delete a specific value within a section of a config.ini file using Python configparser?

I have a config.ini file and I am trying to delete a specific value in a section of my config.ini file. I basically want to delete an index within a list. The config.ini file is: [INPUT] intervals = [[4000, 6000], [25000, 55000]] For example, I…
W. Churchill
  • 346
  • 1
  • 7
  • 28
3
votes
1 answer

How can I get indentation to be included in a multiline value when read from configparser in python?

I have some config file like this: [main] key_one = hello this is indented But when I read it using the configparser library in python like so: import configparser cfg =…
Jonathan Allen Grant
  • 3,408
  • 6
  • 30
  • 53
3
votes
1 answer

Python configparser read config from S3 without downloading

is there a way to read a .ini configuration file from s3 without downloading it? What I have tried: config.ini: [DEFAULT] test = test1 test1 = test2 [ME] me = you you = he code: import boto3 import io import configparser s3_boto =…
3
votes
1 answer

How to parse boolean with config parser

Using python's builtin configparser, I want to parse boolean values in my conf file. Example: [SECTION] foo = False However, when accessing the variable I notice that it is processed as a string. >>> config['SECTION']['foo'] 'False' Furthermore,…
arshbot
  • 12,535
  • 14
  • 48
  • 71
3
votes
1 answer

Parsing .ini files in python

As per the documentation (https://docs.python.org/3/library/configparser.html), I use the configparser for parsing the .ini files Code : import ConfigParser config =…
Harry
  • 3,072
  • 6
  • 43
  • 100
3
votes
2 answers

Python configparser: get list of unused entries

I am using Python's configparser to read an ini file. After parsing, I would like to print a list of entries that have not been used by the parser to inform the user that they have added entries to their ini file that will be ignored. Consider an…
Cerno
  • 751
  • 4
  • 14
3
votes
1 answer

How to use python's configparser to write a file without sections

I need to modify a config file using python. The file has a format similar to property_one = 0 property_two = 5 i.e there aren't any section names. Python's configparser module doesn't support sectionless files, but I can use it to load them…
moly
  • 321
  • 3
  • 14
3
votes
1 answer

gsutil ConfigParser.ParsingError: File contains parsing errors

I'm working on a fastlane lane using pink-room's fastlane firebase test lab plugin which needs a gcloud service account to connect to firebase and upload files to a bucket. The service account is needed because the script runs in a docker container…
Sylvain GIROD
  • 836
  • 1
  • 11
  • 23