Last active
May 7, 2018 07:39
-
-
Save l34marr/5202053 to your computer and use it in GitHub Desktop.
List Temple Data
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
cities = { | |
'KeelungCity': '基隆市', | |
'TaipeiCity': '臺北市', | |
'NewTaipeiCity': '新北市', | |
'TaoyuanCity': '桃園市', | |
'HsinchuCounty': '新竹縣', | |
'HsinchuCity': '新竹市', | |
'MiaoliCounty': '苗栗縣', | |
'TaichungCity': '臺中市', | |
'NantouCounty': '南投縣', | |
'ChanghuaCounty': '彰化縣', | |
'YunlinCounty': '雲林縣', | |
'ChiayiCity': '嘉義市', | |
'ChiayiCounty': '嘉義縣', | |
'TainanCity': '臺南市', | |
'KaohsiungCity': '高雄市', | |
'PingtungCounty': '屏東縣', | |
'YilanCounty': '宜蘭縣', | |
'HualienCounty': '花蓮縣', | |
'TaitungCounty': '臺東縣', | |
'PenghuCounty': '澎湖縣', | |
'LienchiangCounty': '連江縣', | |
'KinmenCounty': '金門縣' | |
} | |
KeelungCity = { | |
'renai': '仁愛區', | |
'zhongshan': '中山區', | |
'jhongjheng': '中正區', | |
'qidu': '七堵區', | |
'nuannuan': '暖暖區', | |
'anle': '安樂區', | |
'sinyi': '信義區' | |
} | |
TaipeiCity = { | |
'zhongzheng': '中正區', | |
'datong': '大同區', | |
'songshan': '松山區', | |
'daan': '大安區', | |
'wanhua': '萬華區', | |
'xinyi': '信義區', | |
'shilin': '士林區', | |
'beitou': '北投區', | |
'neihu': '內湖區', | |
'wenshan': '文山區', | |
'nangang': '南港區', | |
'zhongshan': '中山區' | |
} | |
NewTaipeiCity = { | |
'gungliau': '貢寮區', | |
'sanshia': '三峽區', | |
'linkou': '林口區', | |
'shinjuang': '新莊區', | |
'tucheng': '土城區', | |
'banchiau': '板橋區', | |
'sanchung': '三重區', | |
'junghe': '中和區', | |
'yunghe': '永和區', | |
'sindian': '新店區', | |
'shulin': '樹林區', | |
'yingge': '鶯歌區', | |
'danshuei': '淡水區', | |
'hsichih': '汐止區', | |
'rueifang': '瑞芳區', | |
'lujou': '蘆洲區', | |
'wugu': '五股區', | |
'township': '泰山區', | |
'shenkeng': '深坑區', | |
'shrding': '石碇區', | |
'pinglin': '坪林區', | |
'sanchih': '三芝區', | |
'shimen': '石門區', | |
'pali': '八里區', | |
'pingshi': '平溪區', | |
'shuangshi': '雙溪區', | |
'jinshan': '金山區', | |
'wanli': '萬里區', | |
'wulai': '烏來區' | |
} | |
TaoyuanCity = { | |
'taoyuan': '桃園區', | |
'jungli': '中壢區', | |
'dasi': '大溪區', | |
'yangmei': '楊梅區', | |
'luchu': '蘆竹區', | |
'dayuan': '大園區', | |
'gueishan': '龜山區', | |
'lungtan': '龍潭區', | |
'shinwu': '新屋區', | |
'guanyin': '觀音區', | |
'fushing': '復興區', | |
'pingjen': '平鎮區', | |
'bade': '八德區' | |
} | |
HsinchuCounty = { | |
'chiunglin': '芎林鄉', | |
'kuanhsi': '關西鎮', | |
'judung': '竹東鎮', | |
'sinpu': '新埔鎮', | |
'hengshan': '橫山鄉', | |
'beipu': '北埔鄉', | |
'baushan': '寶山鄉', | |
'emei': '峨眉鄉', | |
'shinfeng': '新豐鄉', | |
'jiangshr': '尖石鄉', | |
'wufeng': '五峰鄉', | |
'jubei': '竹北市', | |
'hukou': '湖口鄉' | |
} | |
HsinchuCity = { | |
'east': '東區', | |
'northern': '北區', | |
'hsiangshan': '香山區' | |
} | |
MiaoliCounty = { | |
'toufen': '頭份鎮', | |
'jhuolan': '卓蘭鎮', | |
'miaoli': '苗栗市', | |
'yuanli': '苑裡鎮', | |
'tungshiang': '通霄鎮', | |
'tunan': '竹南鎮', | |
'houlung': '後龍鎮', | |
'dahu': '大湖鄉', | |
'gungguan': '公館鄉', | |
'tungluo': '銅鑼鄉', | |
'nanjuang': '南庄鄉', | |
'touwu': '頭屋鄉', | |
'sanyi': '三義鄉', | |
'shihu': '西湖鄉', | |
'tzauchiau': '造橋鄉', | |
'sanwan': '三灣鄉', | |
'shrtan': '獅潭鄉', | |
'taian': '泰安鄉' | |
} | |
TaichungCity = { | |
'central': '中區', | |
'east': '東區', | |
'west': '西區', | |
'north': '北區', | |
'south': '南區', | |
'situn': '西屯區', | |
'nantun': '南屯區', | |
'beitun': '北屯區', | |
'fengyuan': '豐原區', | |
'shihkang': '石岡區', | |
'chingshuei': '清水區', | |
'shalu': '沙鹿區', | |
'tungshih': '東勢區', | |
'heping': '和平區', | |
'dajia': '大甲區', | |
'wuchi': '梧棲區', | |
'houli': '后里區', | |
'shengang': '神岡區', | |
'tantz': '潭子區', | |
'daya': '大雅區', | |
'shinshe': '新社區', | |
'waipu': '外埔區', | |
'daan': '大安區', | |
'wurih': '烏日區', | |
'dadu': '大肚區', | |
'lungjing': '龍井區', | |
'wufeng': '霧峰區', | |
'dali': '大里區', | |
'taiping': '太平區' | |
} | |
NantouCounty = { | |
'lugu': '鹿谷鄉', | |
'nantou': '南投市', | |
'yuchr': '魚池鄉', | |
'minjian': '名間鄉', | |
'puli': '埔里鎮', | |
'tazutuen': '草屯鎮', | |
'jushan': '竹山鎮', | |
'jiji': '集集鎮', | |
'jungliau': '中寮鄉', | |
'guoshing': '國姓鄉', | |
'shueili': '水里鄉', | |
'shinyi': '信義鄉', | |
'renai': '仁愛鄉' | |
} | |
ChanghuaCounty = { | |
'jhutang': '竹塘鄉', | |
'shetou': '社頭鄉', | |
'tianwei': '田尾鄉', | |
'shijou': '溪州鄉', | |
'shihu': '溪湖鎮', | |
'yungchin': '永靖鄉', | |
'changhua': '彰化市', | |
'puyan': '埔鹽鄉', | |
'pushin': '埔心鄉', | |
'yuanlin': '員林鎮', | |
'lugang': '鹿港鎮', | |
'huatan': '花壇鄉', | |
'tianjung': '田中鎮', | |
'erlin': '二林鎮', | |
'shianshi': '線西鄉', | |
'shengang': '伸港鄉', | |
'fushing': '福興鄉', | |
'shioushuei': '秀水鄉', | |
'fenyuan': '芬園鄉', | |
'datsuen': '大村鄉', | |
'erhshui': '二水鄉', | |
'pitou': '埤頭鄉', | |
'fangyuan': '芳苑鄉', | |
'dacheng': '大城鄉', | |
'beidou': '北斗鎮', | |
'hemei': '和美鎮' | |
} | |
YunlinCounty = { | |
'shiluo': '西螺鎮', | |
'dongshih': '東勢鄉', | |
'dounan': '斗南鎮', | |
'douliou': '斗六市', | |
'dapi': '大埤鄉', | |
'tuku': '土庫鎮', | |
'beigang': '北港鎮', | |
'erlun': '二崙鄉', | |
'huwei': '虎尾鎮', | |
'gukeng': '古坑鄉', | |
'tsztung': '莿桐鄉', | |
'linnei': '林內鄉 ', | |
'luenbei': '崙背鄉', | |
'mailiau': '麥寮鄉', | |
'baujung': '褒忠鄉', | |
'taishi': '臺西鄉', | |
'yuanchang': '元長鄉', | |
'szhu': '四湖鄉', | |
'kouhu': '口湖鄉', | |
'shueilin': '水林鄉' | |
} | |
ChiayiCity = { | |
'east': '東區', | |
'west': '西區' | |
} | |
ChiayiCounty = { | |
'lutsau': '鹿草鄉', | |
'juchi': '竹崎鄉', | |
'shikou': '溪口鄉', | |
'minshiung': '民雄鄉', | |
'shingang': '新港鄉', | |
'taibau': '太保市', | |
'jungpu': '中埔鄉', | |
'budai': '布袋鎮', | |
'dalin': '大林鎮', | |
'lioujiau': '六腳鄉', | |
'dungshr': '東石鄉', | |
'yiju': '義竹鄉', | |
'shueishang': '水上鄉', | |
'meishan': '梅山鄉', | |
'fanlu': '番路鄉', | |
'dapu': '大埔鄉', | |
'alishan': '阿里山鄉', | |
'putz': '朴子市' | |
} | |
TainanCity = { | |
'north': '北區', | |
'east': '東區', | |
'south': '南區', | |
'anping': '安平區', | |
'annan': '安南區', | |
'westcentral': '中西區', | |
'shiaying': '下營區', | |
'rende': '仁德區', | |
'shinying': '新營區', | |
'chigu': '七股區', | |
'yanshuei': '鹽水區', | |
'jiangjiun': '將軍區', | |
'jiali': '佳里區', | |
'beimen': '北門區', | |
'shinshr': '新市區', | |
'anding': '安定區', | |
'shanshang': '山上區', | |
'baihe': '白河區', | |
'yujing': '玉井區', | |
'madou': '麻豆區', | |
'nanshi': '楠西區', | |
'sinhua': '新化區', | |
'nanhua': '南化區', | |
'shanhua': '善化區', | |
'tzuojen': '左鎮區', | |
'shiuejia': '學甲區', | |
'liouying': '柳營區', | |
'houbi': '後壁區', | |
'lungchi': '龍崎區', | |
'dungshan': '東山區', | |
'yungkang': '永康區', | |
'lioujia': '六甲區', | |
'guantian': '官田區', | |
'danei': '大內區', | |
'guanmiau': '關廟區', | |
'shigang': '西港區', | |
'guiren': '歸仁區' | |
} | |
KaohsiungCity = { | |
'nanzi': '楠梓區', | |
'zuoying': '左營區', | |
'gushan': '鼓山區', | |
'qijin': '旗津區', | |
'lingya': '苓雅區', | |
'qianzhen': '前鎮區', | |
'xinxing': '新興區', | |
'sanmin': '三民區', | |
'xiaogang': '小港區', | |
'qianjin': '前金區', | |
'yancheng': '鹽埕區', | |
'fengshan': '鳳山區', | |
'linyuan': '林園區', | |
'daliau': '大寮區', | |
'yanchau': '燕巢區', | |
'tianliau': '田寮區', | |
'chiautou': '橋頭區', | |
'neimen': '內門區', | |
'chishan': '旗山區', | |
'mailiau': '美濃區', | |
'shanlin': '杉林區', | |
'liouguei': '六龜區', | |
'alian': '阿蓮區', | |
'jiashian': '甲仙區', | |
'gangshan': '岡山區', | |
'dashu': '大樹區', | |
'dashe': '大社區', | |
'renwu': '仁武區', | |
'niausung': '鳥松區', | |
'luju': '路竹區', | |
'mituo': '彌陀區', | |
'tzguan': '梓官區', | |
'hunei': '湖內區', | |
'chieding': '茄萣區', | |
'yungan': '永安區', | |
'tauyuan': '桃源區', | |
'namasia': '那瑪夏區', | |
'maulin': '茂林區' | |
} | |
PingtungCounty = { | |
'gaushu': '高樹鄉', | |
'changjr': '長治鄉', | |
'checheng': '車城鄉', | |
'wanluan': '萬巒鄉', | |
'jutian': '竹田鄉', | |
'chaujou': '潮州鎮', | |
'pingtung': '屏東市', | |
'shinpi': '新埤鄉', | |
'linbian': '林邊鄉', | |
'neipu': '內埔鄉', | |
'jiadung': '佳冬鄉', | |
'jiouru': '九如鄉', | |
'hengchuen': '恆春鎮', | |
'linluo': '麟洛鄉', | |
'yanpu': '鹽埔鄉', | |
'fangliau': '枋寮鄉', | |
'liouchiou': '琉球鄉', | |
'dunggang': '東港鎮', | |
'ligang': '里港鄉', | |
'shinyuan': '新園鄉', | |
'kanding': '崁頂鄉', | |
'nanjou': '南州鄉', | |
'manjou': '滿州鄉', | |
'fangshan': '枋山鄉', | |
'wutai': '霧臺鄉', | |
'majia': '瑪家鄉', | |
'taiwu': '泰武鄉', | |
'laiyi': '來義鄉', | |
'chuenr': '春日鄉', | |
'shrtz': '獅子鄉', | |
'mudan': '牡丹鄉', | |
'sandimen': '三地門鄉', | |
'wandan': '萬丹鄉' | |
} | |
YilanCounty = { | |
'suau': '蘇澳鎮', | |
'luodung': '羅東鎮', | |
'jiaushi': '礁溪鄉', | |
'toucheng': '頭城鎮', | |
'ilan': '宜蘭市', | |
'datung': '大同鄉', | |
'yuanshan': '員山鄉', | |
'dungshan': '冬山鄉', | |
'wujie': '五結鄉', | |
'sanshing': '三星鄉', | |
'juangwei': '壯圍鄉', | |
'nanau': '南澳鄉' | |
} | |
HualienCounty = { | |
'hualien': '花蓮市', | |
'fenglin': '鳳林鎮', | |
'yuli': '玉里鎮', | |
'shincheng': '新城鄉', | |
'jian': '吉安鄉', | |
'shoufeng': '壽豐鄉', | |
'guangfu': '光復鄉', | |
'fengbin': '豐濱鄉', | |
'rueisuei': '瑞穗鄉', | |
'fuli': '富里鄉', | |
'shioulin': '秀林鄉', | |
'juoshi': '卓溪鄉', | |
'wanrung': '萬榮鄉' | |
} | |
TaitungCounty = { | |
'changbin': '長濱鄉', | |
'liudau': '綠島鄉', | |
'lanyu': '蘭嶼鄉', | |
'taitung': '臺東市', | |
'chenggung': '成功鎮', | |
'guanshan': '關山鎮', | |
'beinan': '卑南鄉', | |
'dawu': '大武鄉', | |
'taimali': '太麻里鄉', | |
'tonghe': '東河鄉', | |
'luye': '鹿野鄉', | |
'jinfeng': '金峰鄉 ', | |
'daren': '達仁鄉', | |
'haiduan': '海端鄉', | |
'yanping': '延平鄉', | |
'chrshang': '池上鄉' | |
} | |
PenghuCounty = { | |
'magung': '馬公市', | |
'hushi': '湖西鄉', | |
'baisha': '白沙鄉', | |
'shiyu': '西嶼鄉', | |
'wangan': '望安鄉', | |
'chimei': '七美鄉' | |
} | |
LienchiangCounty = { | |
'nangan': '南竿鄉', | |
'beigan': '北竿鄉', | |
'jiuguang': '莒光鄉', | |
'dungyin': '東引鄉' | |
} | |
KinmenCounty = { | |
'jincheng': '金城鎮', | |
'jinhu': '金湖鎮', | |
'jinning': '金寧鄉', | |
'jinsha': '金沙鎮', | |
'lieyu': '烈嶼鄉', | |
'wuchiou': '烏坵鄉' | |
} |
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
cities = { | |
'TainanCity': '臺南市', | |
'TaipeiCity': '臺北市', | |
'TaichungCity': '臺中市' | |
} | |
TainanCity = { | |
'baihe': '白河區', | |
'north': '北區' | |
} | |
ids = ( | |
'1103004-FTF', | |
'1103022-NWG', | |
'2104052-KJLJD' | |
) | |
from Products.CMFCore.utils import getToolByName | |
request = container.REQUEST | |
catalog = getToolByName(context, 'portal_catalog') | |
path = '/mysite/myfolder' | |
for id in ids: | |
for brain in catalog(portal_type='MyType', path=path, id=id): | |
c, t = brain.getURL().split('/')[-3:-1] | |
if c in cities.keys(): | |
city = cities[c] | |
if t in TainanCity.keys(): | |
town = TainanCity[t] | |
obj = brain.getObject() | |
d_host = ','.join(obj.getDeity_host()) | |
deity_host = '{'+d_host+'}' | |
d_company = ','.join(obj.getDeity_company()) | |
deity_company = '{'+d_company+'}' | |
print "INSERT INTO my_table \ | |
(name, religion, funding, organize, address, promoter, tel, era, \ | |
geo_kind, countyname, townname, data_sourc, t_code, deity_host, \ | |
era_end, year_accuracy, deity_company, registered) \ | |
VALUES (" + \ | |
"'" + brain.Title + "', " + "'" + obj.religion + "', " + \ | |
"'" + obj.funding + "', " + "'" + obj.organizing + "', " + \ | |
"'" + obj.address + "', " + "'" + obj.in_charge + "', " + \ | |
"'" + obj.tel + "', " + "'" + obj.era + "', " + \ | |
"'" + obj.coordinate + "', " + "'" + city + "', " + \ | |
"'" + town + "', " + "'" + obj.data_src + "', " + \ | |
"'" + obj.id + "', " + "'" + deity_host + "', " + \ | |
"'" + obj.era_end + "', " + "'" + obj.year_accuracy + "', " + \ | |
"'" + deity_company + "', " + "'" + obj.registered + "'" + ");" | |
return printed |
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
from Products.CMFCore.utils import getToolByName | |
request = container.REQUEST | |
catalog = getToolByName(context, 'portal_catalog') | |
path = '/mysite/myfolder' | |
for brain in catalog(portal_type='MyType', path=path): | |
#try: | |
# obj = brain.getObject() | |
# print "%s, %s" % \ | |
# (brain.getPath(), obj.getFlxt()) | |
print brain.getPath().split('/')[5] | |
#except: | |
# pass | |
return printed |
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
cities = { | |
'KeelungCity': '基隆市', | |
'TaipeiCity': '臺北市', | |
'NewTaipeiCity': '新北市', | |
'TaoyuanCounty': '桃園縣', | |
'HsinchuCounty': '新竹縣', | |
'HsinchuCity': '新竹市', | |
'MiaoliCounty': '苗栗縣', | |
'TaichungCity': '臺中市', | |
'NantouCounty': '南投縣', | |
'ChanghuaCounty': '彰化縣', | |
'YunlinCounty': '雲林縣', | |
'ChiayiCity': '嘉義市', | |
'ChiayiCounty': '嘉義縣', | |
'TainanCity': '臺南市', | |
'KaohsiungCity': '高雄市', | |
'PingtungCounty': '屏東縣', | |
'YilanCounty': '宜蘭縣', | |
'HualienCounty': '花蓮縣', | |
'TaitungCounty': '臺東縣', | |
'PenghuCounty': '澎湖縣', | |
'LienchiangCounty': '連江縣', | |
'KinmenCounty': '金門縣' | |
} | |
for id in cities.keys(): | |
print id, '= {' | |
for k in container['temples'][id].objectIds(): | |
print "'"+k+"': '"+container['temples'][id][k].Title()+"'," | |
print '}' | |
return printed |
if t in eval(c).keys():
Note that eval() seems not available for RestrictedPython Script.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sudo su - postgres
psql -d MY_DB_NAME
\copy (SELECT t_code, era, name FROM my_table) TO '/tmp/file-to-save.txt' WITH CSV