problem writing to a file each record read

Peter Otten __peter__ at web.de
Wed Mar 15 02:34:50 EST 2006


Eduardo Biano wrote:

> #-----------------------------------
> #  This is the problem code. Ten records
> #  is  lump into 1 row and written
> #  in the output file.
> #
> #  My expected output is 10 rows.
> #-----------------------------------
> info = string.join([fn, mi, ln, deg, dat]

Should probably be ",".join([fn, mi, ln, deg, dat])

> outfile.write(info)

You have to add a newline explicitly if you want one:

outfile.write("\n") 

Using the csv module that comes with Python may simplify your task a lot.

Peter



More information about the Python-list mailing list