Help with language, dev tool selection
Fredrik Lundh
fredrik at pythonware.com
Sat Oct 22 09:24:40 EDT 2005
vasilijepetkovic at yahoo.com wrote:
> I have a flat text file, 30000 records, each record has two columns,
> the columns are tab separated.
>
> The file looks like this (approximately)
>
> Sarajevo 431104-133111
(when did they move sarajevo to italy?)
> Mostar 441242-133421
> Zagreb 432322-134423
here's a straightforward Python solution:
HEADER = "This page displays longitude-latitude information"
SUBHEADER = "Grad"
for line in open("datafile.txt"):
town, latlong = line.split()
lat, long = latlong.split("-")
f = open(town + ".html", "w")
f.write(HEADER + "\n")
f.write(SUBHEADER + "\n")
f.write(town + "\n")
f.write(long + " " + lat + "\n")
f.close()
# end
tweak as necessary. see the Python tutorial for help:
http://docs.python.org/tut/tut.html
</F>
More information about the Python-list
mailing list