file reading in python
Posted
by
Jagdev
on Stack Overflow
See other posts from Stack Overflow
or by Jagdev
Published on 2011-03-15T13:47:40Z
Indexed on
2011/03/16
16:10 UTC
Read the original article
Hit count: 401
So my whole problem is that I have two files one with following format(for Python 2.6):
#comments
config = {
#comments
'name': 'hello',
'see?': 'world':'ABC',CLASS=3
}
This file has number of sections like this. Second file has format:
[23]
[config]
'name'='abc'
'see?'=
[23]
Now the requirement is that I need to compare both files and generate file as:
#comments
config = {
#comments
'name': 'abc',
'see?': 'world':'ABC',CLASS=3
}
So the result file will contain the values from the first file, unless the value for same attribute is there in second file, which will overwrite the value. Now my problem is how to manipulate these files using Python.
Thanks in advance and for your previous answers in short time ,I need to use python 2.6
© Stack Overflow or respective owner