Created
February 21, 2019 09:17
-
-
Save Cediddi/57cf67e4ba8538d62c3e8f4a82c7e2f0 to your computer and use it in GitHub Desktop.
Python için güncel Türkiye il ilçe deposu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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