Hi John, what do you think about this?
def InplaceReplace(filename): lines = open(filename, 'r').readlines() lines = [line.replace(' ', '') for line in lines] open(filename, 'wt').writelines(lines) It works well on so small files. Yours sincerely, ______________________________ János Juhász > Message: 2 > Date: Tue, 4 Apr 2006 22:33:18 +0100 > From: "John Corry" <[EMAIL PROTECTED]> > Subject: [Tutor] Space the final frontier! > To: <tutor@python.org> > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset="iso-8859-1" > Dear All, > I am having difficulty removing white spaces from my file. The file is 999 > lines long and looks like the sample below: > 001, new field,dial= 028 90 79 0154, dial= > 002, borfiled, dial= 02890 618521, dial= > 003, newcomp, dial=02890419689, dial= > The program, I am using to import the file does not like the spaces around > the numbers. The number should look like the "dial=02890419689" in the > third line. Thus the sample above should look like: > 001,newfield,dial=02890790154,dial= > 002,borfiled,dial=02890618521,dial= > 003,newcomp,dial=02890419689,dial= _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor