Improve performance for writing files with format modification

christine.bartels at teleatlas.com christine.bartels at teleatlas.com
Tue Dec 18 05:57:49 EST 2001


Hi!

I need some help to improve a function that formats a string and
writes the result to a file.
...
file = open(filein,"r")
nfile = open(fileout,"w")
while 1:
	fblock = file.readlines(0x2000)
	if not fblock: break
	for i in fblock:
		nfile.write("%20s%10s" % tuple(split(';')))
nfile.close()
...

I want to use python but at the moment the write-function takes so
much time that I prefer gawk for this conversion (3 times faster!). Is
there anybody who knows a way to improve the write-function?

Cheers,
Tine



More information about the Python-list mailing list