Skip to content

Instantly share code, notes, and snippets.

View t0mst0ne's full-sized avatar

ChenChang Shih t0mst0ne

View GitHub Profile
@t0mst0ne
t0mst0ne / er.kcgmh.py
Last active August 29, 2015 14:04
Parsing ER information from KCGMH
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import re
import time
import json
import os
os.environ['TZ'] = 'ROC'
@t0mst0ne
t0mst0ne / er.mmh.tpe.py
Last active August 29, 2015 14:04
馬偕醫院
#!/usr/bin/env python
#coding:UTF-8
# 馬偕 by t0mst0ne
import os
import re
import json
import requests
os.environ['TZ'] = 'ROC'
@t0mst0ne
t0mst0ne / er.cych.py
Last active August 29, 2015 14:05
嘉義基督教醫院
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 嘉義基督教醫院
import requests
import re
import time
import json
import os
os.environ['TZ'] = 'ROC'
@t0mst0ne
t0mst0ne / npolist_to_pandas.py
Last active August 29, 2015 14:05
manage npolist.json
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pandas as pd
data = pd.read_json('npolist.json',orient="columns")
type(data)
data
@t0mst0ne
t0mst0ne / Parse_address_HUA.py
Created September 7, 2014 13:56
Parse Poll station address from 13th TW president election Poll station data
#!/usr/bin/env python
#coding:UTF-8
import pandas as pd
HUA = pd.io.parsers.read_csv('https://raw.githubusercontent.com/g0v/cec/master/2014/booth/HUA.csv')
pre = pd.io.parsers.read_csv('https://raw.githubusercontent.com/g0v/cec/master/13th.csv',sep='\t')
pre['together'] = pre['縣市碼']+pre['投票所名稱']
mydict = pre.set_index('together')['地址'].to_dict()
HUA['Address2'] = '花蓮縣' + HUA['投開票所設置處所']
import pandas as pd
for i in range (1, 21):
data = pd.read_csv('../' + str(i) + '.csv')
delta = data["Total"] - data["First"] - data["Second"] - data["Third"]
data['delta'] = delta
data['one'] = 1
Age = data.ix[data20['County']=='TPE']
Age = pd.tools.pivot.pivot_table(Age, values='one', index=['delta'], columns=['Age'],aggfunc=np.sum, margins = False)
print Age.T.plot()
Age.T.plot().savefig('/path/to/figure.pdf')
@t0mst0ne
t0mst0ne / pharmacy.info.py
Last active August 29, 2015 14:07
Parse the pharmacy information from data.fda.gov.tw
#coding:UTF-8
import xml.etree.cElementTree as ET
import pandas as pd
from pygeocoder import Geocoder
import urllib
import time
feed = urllib.urlopen("http://data.fda.gov.tw/cacheData/35_1.xml;jsessionid=C8F4570A382FF8BFC9CC901CD802F0EF")
tree = ET.parse(feed)
#!/usr/bin/env python
#coding:UTF-8
import requests
import re
import json
import pandas as pd
import datetime
headers = {'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
@t0mst0ne
t0mst0ne / icd10_xpath.py
Last active August 29, 2015 14:08
ICD10data.com xpath
#!/usr/bin/env python
#coding:UTF-8
import requests
from scrapy.selector import Selector
r = requests.get('http://www.icd10data.com/ICD10CM/Codes/C00-D49/C00-C14/C03-/C03.1')
Selector(text=r.text).xpath('//a[contains(@href, "/ICD10CM/DRG/")]/@href').extract()
#!/usr/bin/env python
#coding:UTF-8
# revised on 2014.10.31 due to website change
import requests, json, os, re
from datetime import datetime
os.environ['TZ'] = 'ROC'
html = requests.get('http://hlm.tzuchi.com.tw/html/hlinfos.html')
query = re.findall(u'<em>(.*?)</em>', html.text)
full_reported = False if u'N' in query[0] else True