Re: Newline at EOF Removal

2006-01-09 Thread Mike Meyer
"Alex N" <[EMAIL PROTECTED]> writes: > Peter gave me a good clue here > w.write(f.read().rstrip('\n') + '\n') > However the 2nd \n puts that empty line at the end of the file so I No, it doesn't. Well, maybe it doesn't, depending on how your applications treats newlines. Normally, a newline termin

Re: Newline at EOF Removal

2006-01-09 Thread Tim Peters
[Bengt Richter] > ... > [1] BTW, I didn't see the 't' mode in > http://docs.python.org/lib/built-in-funcs.html > description of open/file, but I have a nagging doubt about saying it's not > valid. > Where did you see it? 't' is a Windows-specific extension to standard C's file modes. Python pas

Re: Newline at EOF Removal

2006-01-09 Thread Alex N
Actually Im doing a process with PHP, Unicode, Ansi. I am trying to format these text files to be acceptable to PHP. The first process is to strip the unicode and convert to ansi. But there are blank lines in the file and at the end of the file. I was just having trouble with the lines at the end.

Re: Newline at EOF Removal

2006-01-09 Thread Alex N
Thank you guys for all your help. Was able to nail it down. uh I dunno where i saw the 'wt' at. somewhere online though. I have to do it in 2 stages though and run through a coula files but it works. import re f = open("oldfile.txt") w = open("newfile.txt", "w") for line in f: if line.strip():

Re: Newline at EOF Removal

2006-01-09 Thread Dylan Wilson
Do you mean somthing like this? >>> f = open("file.txt") >>> w = open('outfile.txt', 'w') >>> for line in f.split('\n'): ...w.write(line) ... >>> w.close() >>> '\n' in open('/home/wandleg/outfile.txt').read() False -- http://mail.python.org/mailman/listinfo/python-list

Re: Newline at EOF Removal

2006-01-08 Thread Bengt Richter
On Sun, 08 Jan 2006 17:10:01 -0600, "Alex Nordhus" <[EMAIL PROTECTED]> wrote: > > >I am looking for a way to strip the blank line and the empty newline at >the end of the text file. I can get the blank lines removed from the >file but it always leaves the end line (which is blank) as a newline. My

Re: Newline at EOF Removal

2006-01-08 Thread Mike Meyer
"Alex Nordhus" <[EMAIL PROTECTED]> writes: > I am looking for a way to strip the blank line and the empty newline at > the end of the text file. I can get the blank lines removed from the > file but it always leaves the end line (which is blank) as a newline. My > code is here and it works but leav

Re: Newline at EOF Removal

2006-01-08 Thread Peter Hansen
Alex Nordhus wrote: > > I am looking for a way to strip the blank line and the empty newline at > the end of the text file. I can get the blank lines removed from the > file but it always leaves the end line (which is blank) as a newline. My > code is here and it works but leaves the newline at th

Newline at EOF Removal

2006-01-08 Thread Alex Nordhus
I am looking for a way to strip the blank line and the empty newline at the end of the text file. I can get the blank lines removed from the file but it always leaves the end line (which is blank) as a newline. My code is here and it works but leaves the newline at the end of the file. How do I g