Newline at EOF Removal

Alex N megahrtz at gte.net
Sun Jan 8 22:44:56 EST 2006


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. PHP blows up if there is a blank or empty line in the
text files. So thats where i was at.
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
tried it with just
w.write(f.read().rstrip('\n'))
and it works great!

Now I can go on to the next step. Thank you guys for your help

Alex




More information about the Python-list mailing list