[EMAIL PROTECTED] wrote: >Hello All, > >I have a problem with the program that should generate x number of txt >files (x is the number of records in the file datafile.txt). > >Once I execute the program (see below) only one file (instead of x >files) is created. The file created is based on the last record in >datafile.txt. > >The program is as follows: >==================================== >#! python > >HEADER = "This page displays longitude-latitude information" >SUBHEADER = "City" > >for line in open("datafile.txt"): > > > town, latlong = line.split('\t') > >f = open(town + ".txt", "w+") > >f.write(HEADER + "\n") >f.write(SUBHEADER + ": " + town + "\n") >f.write("LAT/LONG" + ": " + latlong + "\n") >f.close() > > > These lines need to be within your loop.
J -- http://mail.python.org/mailman/listinfo/python-list