Newline at EOF Removal

Alex N megahrtz at gte.net
Mon Jan 9 05:21:58 CET 2006


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():

        w.write(line)


f.close()
w.close()

g = open("newfile.txt")
x = open("mynewfile.txt", "w")

x.write(g.read().rstrip('\n'))

x.close()

Got around the I/O errors luckily
thanks guys




More information about the Python-list mailing list