docs: def parse_geonames_data(lines_iterator):
      """
      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:
      """
      data_headers = []
      num_created = 0
      num_updated = 0
      for line in lines_iterator:
          line = line.decode()
          if line[0] == "#":
              if line[0:4] == "#ISO":
                  data_headers = line.strip('# ').split('\t')
                  if data_headers != DATA_HEADERS_ORDERED:
                      raise GeonamesParseError(
                          "The table headers do not match the expected headers.")
              continue
          if not data_headers:
              raise GeonamesParseError("No table headers found.")
          bits = line.split('\t')
  
          data = {DATA_HEADERS_MAP[DATA_HEADERS_ORDERED[x]]: bits[x] for x in range(0, len(bits))}
          if 'currency_code' in data and data['currency_code']:
              data['currency_symbol'] = CURRENCY_SYMBOLS.get(data['currency_code'])
  
          # Remove empty items
          clean_data = {x: y for x, y in data.items() if y}
  
          # Puerto Rico and the Dominican Republic have two phone prefixes in the format "123 and
          # 456"
          if 'phone' in clean_data:
              if 'and' in clean_data['phone']:
                  clean_data['phone'] = ",".join(re.split('\s*and\s*', clean_data['phone']))
  
          # Avoiding update_or_create to maintain compatibility with Django 1.5
          try:
              country = Country.objects.get(iso=clean_data['iso'])
              created = False
          except Country.DoesNotExist:
              try:
                  country = Country.objects.create(**clean_data)
              except ValidationError as e:
                  raise GeonamesParseError("Unexpected field length: %s" % e.message_dict)
              created = True
  
          for k, v in six.iteritems(clean_data):
              setattr(country, k, v)
  
          try:
              country.save()
          except ValidationError as e:
              raise GeonamesParseError("Unexpected field length: %s" % e.message_dict)
  
          if created:
              num_created += 1
          else:
              num_updated += 1
      return num_updated, num_created