C
CSUIDL PROGRAMMEr
folks
I am new to python, so excuse me if i am asking stupid questions.
I have a txt file and here are some lines of it
Document<Keyword<date:2006-08-19> Keyword<time:11:00:43>
I am writing a python program to replace the tags and word Document
with Doc.
Here is my python program
#! /usr/local/bin/python
import sys
import string
import re
def replace():
filename='/root/Desktop/project/chatlog_20060819_110043.xml.txt'
try:
fh=open(filename,'r')
except:
print 'file not opened'
sys.exit(1)
for l in
open('/root/Desktop/project/chatlog_20060819_110043.xml.txt'):
l=l.replace("Document", "DOC")
fh.close()
if __name__=="__main__":
replace()
But it does not replace Document with Doc in the txt file
Is there anything wrong i am doing
thanks
I am new to python, so excuse me if i am asking stupid questions.
I have a txt file and here are some lines of it
Document<Keyword<date:2006-08-19> Keyword<time:11:00:43>
Keyword<receiver:> Keyword<data::+iwx> Keyword<mode::+iwxKeyword said:> Keyword<date:2006-08-19> Keyword<time:11:00:44> Keyword<sender:>
I am writing a python program to replace the tags and word Document
with Doc.
Here is my python program
#! /usr/local/bin/python
import sys
import string
import re
def replace():
filename='/root/Desktop/project/chatlog_20060819_110043.xml.txt'
try:
fh=open(filename,'r')
except:
print 'file not opened'
sys.exit(1)
for l in
open('/root/Desktop/project/chatlog_20060819_110043.xml.txt'):
l=l.replace("Document", "DOC")
fh.close()
if __name__=="__main__":
replace()
But it does not replace Document with Doc in the txt file
Is there anything wrong i am doing
thanks