John Corry wrote: > Your advice was spot on. I have enclosed the code that I ended up with. > Instead of appending it to a list, I just wrote it to another file in the > corrected format.
A few notes below: > > > filename = "a:/calllist.csv" > filename2 = "c:/calllist.csv" > import string > import os > import re > listy = [] You don't use string, os or listy so these lines can be removed > input = open( filename, 'r') #read access > input2 = open(filename2, 'w') > for line in input.readlines(): > line = re.sub('[\s]+', '', line) > y = line > x = "\n" > z = y + x > input2.write(z) I would write either line += "\n" input2.write(line) or input2.write(line) input2.write("\n") BTW input2 is not such a good name for an output file! > > del input > del input2 del is not needed here, you should use input.close() # not really needed input2.close() I say "not really needed" because for an input file you probably don't care exactly when it is closed. For an output file I always close it as soon as I am done writing. But maybe I am just teaching my own bad habits here! Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor