Re: Regular expression worries

2006-10-11 Thread Bruno Desthuilliers
CSUIDL PROGRAMMEr wrote: > folks > I am new to python, so excuse me if i am asking stupid questions. >From what I see, you seem to be new to programming in general !-) > I have a txt file and here are some lines of it > > Document Keyword > Keyword Keyword > Keyword > Keyword Keyword Keyword

Re: Regular expression worries

2006-10-11 Thread Tim Chase
> for l in > open('/root/Desktop/project/chatlog_20060819_110043.xml.txt'): > > l=l.replace("Document", "DOC") > fh.close() > > But it does not replace Document with Doc in the txt file In addition to closing the file handle for the loop *within* the loop, you're changing "l" (s

Re: Regular expression worries

2006-10-11 Thread johnzenger
You are opening the same file twice, reading its contents line-by-line into memory, replacing "Document" with "Doc" *in memory*, never writing that to disk, and then discarding the line you just read into memory. If your file is short, you could read the entire thing into memory as one string usin

Regular expression worries

2006-10-11 Thread 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 Keyword Keyword Keyword Keyword Keyword Keyword Keyword Keyword Keywordhttp://mail.python.org/mailman/listinfo/python-list