Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
indic_osm_history_data
import requests
import dataset
db = dataset.connect('sqlite:///:memory:')
table = db['indic_osm_history_data']
language_codes = {"kn":"Kannada","mr":"Marathi","ne":"Nepali","ta":"Tamil","hi":"Hindi","ur":"Urdu","ml":"Malayalam","bn":"Bengali","te":"Telugu","pa":"Punjabi"}
for language_code in language_codes.keys():
url="http://taghistory.raifer.tech/***/name%3A"+language_code+"/"
print str(url)
language = language_codes[language_code]
r = requests.get(url)
data = r.json()
for item in data:
print str(item)
date = str(item['date'])[0:10]
count = item['count']
row = table.find_one(date=date)
r = {'date':date,language:count}
if row:
table.update(r, ['date'])
else:
table.insert(r)
result = table.all()
dataset.freeze(result, format='csv', filename='indic_osm_tag_history_data.csv')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.