def parse_geonames_data(lines_iterator):
data_headers = []<EOL>num_created = <NUM_LIT:0><EOL>num_updated = <NUM_LIT:0><EOL>for line in lines_iterator:<EOL><INDENT>line = line.decode()<EOL>if line[<NUM_LIT:0>] == "<STR_LIT:#>":<EOL><INDENT>if line[<NUM_LIT:0>:<NUM_LIT:4>] == "<STR_LIT>":<EOL><INDENT>data_headers = line.strip('<STR_LIT>').split('<STR_LIT:\t>')<EOL>if data_headers != DATA_HEADERS_ORDERED:<EOL><INDENT>raise GeonamesParseError(<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>continue<EOL><DEDENT>if not data_headers:<EOL><INDENT>raise GeonamesParseError("<STR_LIT>")<EOL><DEDENT>bits = line.split('<STR_LIT:\t>')<EOL>data = {DATA_HEADERS_MAP[DATA_HEADERS_ORDERED[x]]: bits[x] for x in range(<NUM_LIT:0>, len(bits))}<EOL>if '<STR_LIT>' in data and data['<STR_LIT>']:<EOL><INDENT>data['<STR_LIT>'] = CURRENCY_SYMBOLS.get(data['<STR_LIT>'])<EOL><DEDENT>clean_data = {x: y for x, y in data.items() if y}<EOL>if '<STR_LIT>' in clean_data:<EOL><INDENT>if '<STR_LIT>' in clean_data['<STR_LIT>']:<EOL><INDENT>clean_data['<STR_LIT>'] = "<STR_LIT:U+002C>".join(re.split('<STR_LIT>', clean_data['<STR_LIT>']))<EOL><DEDENT><DEDENT>try:<EOL><INDENT>country = Country.objects.get(iso=clean_data['<STR_LIT>'])<EOL>created = False<EOL><DEDENT>except Country.DoesNotExist:<EOL><INDENT>try:<EOL><INDENT>country = Country.objects.create(**clean_data)<EOL><DEDENT>except ValidationError as e:<EOL><INDENT>raise GeonamesParseError("<STR_LIT>" % e.message_dict)<EOL><DEDENT>created = True<EOL><DEDENT>for k, v in six.iteritems(clean_data):<EOL><INDENT>setattr(country, k, v)<EOL><DEDENT>try:<EOL><INDENT>country.save()<EOL><DEDENT>except ValidationError as e:<EOL><INDENT>raise GeonamesParseError("<STR_LIT>" % e.message_dict)<EOL><DEDENT>if created:<EOL><INDENT>num_created += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>num_updated += <NUM_LIT:1><EOL><DEDENT><DEDENT>return num_updated, num_created<EOL>
Parses countries table data from geonames.org, updating or adding records as needed.
currency_symbol is not part of the countries table and is supplemented using the data
obtained from the link provided in the countries table.
:type lines_iterator: collections.iterable
:return: num_updated: int, num_created: int
:raise GeonamesParseError: