[Tutor] Removing characters
Blake.Garretson@dana.com
Blake.Garretson@dana.com
Mon, 15 Oct 2001 10:55:13 -0400
Danny already posted a much better program, but here's my version that I
wrote a while ago that does something similar. This overwrites the file,
but you could easily change it to write to a different file.
# strips off endline stuff
import sys, string
for filename in sys.argv[1:]:
infile=open(filename,'r')
text=file.read()
text=string.replace(text,"\n","")
text=string.replace(text,"\r","")
infile.close()
outfile=open(filename,'w')
outfile.write(text)
outfile.close()
-Blake Garretson
>Date: Sun, 14 Oct 2001 19:38:27 -0400 (EDT)
>From: "Timothy M. Brauch" <tmbrau00@centre.edu>
>Subject: [Tutor] Removing characters
>
>I know there must a simple way to open a file and remove all the end of
>line characters and/or carriage returns. However, I can't seem to get it
>to work right. Any help?
>
> - Tim