Changeset 578
- Timestamp:
- 02/17/10 14:18:14 (5 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/telemeta/management/commands/telemeta-geocode.py
r576 r578 21 21 raise CommandError("Unable to open %s" % datafile) 22 22 23 locations = Location.objects.filter(type=Location.COUNTRY) 23 locations = [l for l in Location.objects.filter(type=Location.COUNTRY)] 24 24 25 i = 0 25 26 geocoded = 0 26 total = l ocations.count()27 total = len(locations) 27 28 for line in datafile: 28 29 (geonameid, name, asciiname, alternatenames, latitude, longitude, feature_class, … … 30 31 admin4_code, population, elevation, gtopo30, timezone, modification_date) = line.strip().split("\t") 31 32 32 if feature_c lass == 'A':33 if feature_code[0:3] == 'PCL': 33 34 names = [asciiname.lower()] 34 35 if alternatenames: 35 36 names.extend([unaccent(n).lower() for n in alternatenames.split(',')]) 36 37 38 found = [] 37 39 for l in locations: 38 40 if unaccent(l.name).lower() in names: … … 41 43 l.save() 42 44 geocoded += 1 45 found.append(l) 46 47 for l in found: 48 locations.remove(l) 43 49 44 50 i += 1
