473,396 Members | 1,768 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Question re ConfigParser

Given a section like

[Data]
value1
value2
value3
Can ConfigParser be easily used to put the values in a dictionary? If
so, how?


Aug 20 '08 #1
2 815
On Aug 20, 5:34*pm, loial <jldunn2...@googlemail.comwrote:
Given a section like

[Data]
value1
value2
value3

Can ConfigParser be easily used to put the values in a dictionary? If
so, how?
Dictionaries are key/value pairs. Do you expect 'value1' to be a key
or a value?

If the data is literally as you describe, and not key/value entries
(such as 'key1: value1' or 'key1=value1'), you would probably be
better off just stepping through the file, testing for the [data]
section and then reading the following lines into a list.
Aug 20 '08 #2
On 20 Aug, 13:49, alex23 <wuwe...@gmail.comwrote:
On Aug 20, 5:34*pm, loial <jldunn2...@googlemail.comwrote:
Given a section like
[Data]
value1
value2
value3
Can ConfigParser be easily used to put the values in a dictionary? If
so, how?

Dictionaries are key/value pairs. Do you expect 'value1' to be a key
or a value?

If the data is literally as you describe, and not key/value entries
(such as 'key1: value1' or 'key1=value1'), you would probably be
better off just stepping through the file, testing for the [data]
section and then reading the following lines into a list.
Thanks. Thats what I did in the end
Aug 21 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Greg Krohn | last post by:
I'm trying to subclass ConfigParser so I can use a custom __read method (the custom format doesn't conform to RFC 822) when needed. Needless to say, it's not working as expected. In the...
2
by: Roy H. Berger | last post by:
If I want to subclass ConfigParser and changed the optionxform method to not return things in lower case wouldn't I just need the following code in my subclasss module? from ConfigParser import...
2
by: rzed | last post by:
I am working with PythonCard in one of my apps. For its purposes, it uses an .ini file that is passed to ConfigParser. For my app, I also need configuration information, but for various reasons,...
1
by: pipehappy | last post by:
Hello everyone: I came across the module ConfigParser and can use it correctly. import ConfigParser fp = open('test.cfg','w+') config = ConfigParser.ConfigParser() config.readfp(fp)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.