Permalink
Browse files

Limit the maximum splits while parsing ADM2 codes

It seems there's an ADM2 code which includes dots,
which is also the separator for all the codes
defining the ADM2 (country code.ADM1 code.ADM2 code).
By limiting the number of splits, we can parse it
without problems.
  • Loading branch information...
1 parent a41753d commit 921059becf9d1d7fd07c074673f7de1d7c529362 @fiam committed Nov 26, 2008
Showing with 1 addition and 1 deletion.
  1. +1 −1 geonames-import
View
@@ -231,7 +231,7 @@ class GeonamesImporter(object):
line = fd.readline()[:-1]
while line:
codes, name, ascii_name, geoname_id = line.split('\t')
- country_id, adm1, code = codes.split('.')
+ country_id, adm1, code = codes.split('.', 2)
try:
admin1 = self.admin1_codes[country_id][adm1]
except KeyError:

0 comments on commit 921059b

Please sign in to comment.