file IO

Darren Dale dd55 at
Tue Aug 3 02:52:33 CEST 2004

Can anyone explain this?

I have a file called old.dat with two lines:


So it's 3 bytes long. I run the following:

import os
f = file('old.dat',mode='r')
olddata = f.readlines()

f = file('new.dat',mode='w')

new.dat is now 4 bytes long. ???

I need to reformat and then save some data.   Then I need to be able to 
export the reformatted data to a spreadsheet-friendly format. But once I 
have simply copied (trying to isolate the problem) the file using the 
script above, my export function takes 10x as long as it would have with 
the original file. And worse, the output has an extra newline character 
added at the end of each line. Any suggestions would really be 
appreciated, I am going a bit crazy trying to understand this.


More information about the Python-list mailing list