crashovaride
July 28th, 2007, 01:49 AM
Hi all,
I'm trying to write a python application which will read from a file, and add to the strings it reads, this is what i have so far, and everything i have tried, it will not append to the string...
data_file = open('/root/Desktop/social.log', 'rb')
for line in data_file:
print line
filehandle = open ('/root/Desktop/config.log', 'a')
filehandle.write (line + "ending of string")
data_file.close()
filehandle.close()
Where the "ending of string" is, is where i want to add to line. So, if line is "hello " i would want it printed in the file as "hello ending of string" As all i could get it to do was "ending of string hello" and i would like to place it the other way.
Any ideas? Can anyone please help?
Thank you,
Crash.
I'm trying to write a python application which will read from a file, and add to the strings it reads, this is what i have so far, and everything i have tried, it will not append to the string...
data_file = open('/root/Desktop/social.log', 'rb')
for line in data_file:
print line
filehandle = open ('/root/Desktop/config.log', 'a')
filehandle.write (line + "ending of string")
data_file.close()
filehandle.close()
Where the "ending of string" is, is where i want to add to line. So, if line is "hello " i would want it printed in the file as "hello ending of string" As all i could get it to do was "ending of string hello" and i would like to place it the other way.
Any ideas? Can anyone please help?
Thank you,
Crash.