Skip to content

Instantly share code, notes, and snippets.

@Cediddi
Created February 21, 2019 09:17
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cediddi/57cf67e4ba8538d62c3e8f4a82c7e2f0 to your computer and use it in GitHub Desktop.
Save Cediddi/57cf67e4ba8538d62c3e8f4a82c7e2f0 to your computer and use it in GitHub Desktop.
Python için güncel Türkiye il ilçe deposu
#!/usr/bin/env python3
"""
Bu script İçişleri Bakanlığının yayınladığı il/ilçe listesini okuyup size bir sözlük olarak geri verir, aslında başka şeyler de yapabilir, ben yapmadım üşendim, siz isterseniz yapın.
"""
__author__ = "Umut Karcı"
__license__ = "MIT"
from tablib import Dataset
from urllib.request import urlopen
from collections import defaultdict
response = urlopen("https://www.nvi.gov.tr/PublishingImages/Pages/il-ilce-kod-tablosu/IL_ILCE_LISTESI.xls")
imported_data = Dataset().load(response.read(), "xls")
il_ilce_map = defaultdict(list)
for row in filter(lambda x:x[4] == 'ETKİN', imported_data):
il_ilce_map[row[1]].append(row[3])
il_ilce_map = dict(il_ilce_map)
print(il_ilce_map)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment