Skip to content

Instantly share code, notes, and snippets.

@thejeshgn
Created September 18, 2016 15:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thejeshgn/ef63348b558b59101b470f2b1cbbedf4 to your computer and use it in GitHub Desktop.
Save thejeshgn/ef63348b558b59101b470f2b1cbbedf4 to your computer and use it in GitHub Desktop.
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