Created
May 24, 2017 09:35
-
-
Save staybuzz/bc3b300913c5a5250c395e270aa05259 to your computer and use it in GitHub Desktop.
「分けちよ!」のゴミ情報をCSVにするやつ
This file contains hidden or 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
#coding: utf-8 | |
from plistlib import readPlist | |
import csv | |
type_plist = readPlist("type.plist") | |
dict_plist = readPlist("dictionary.plist") | |
# 分類IDと分類名を格納 | |
# dict型のキーにID、値に分類名を格納 | |
gomi_type = {} | |
for t in type_plist: | |
gomi_type[t["typeID"]] = t["name"] | |
# ゴミの名前とその分類を辞書に格納 | |
gomi_dict = {} | |
for gomi in dict_plist: | |
gomi_dict[gomi["name"]] = gomi_type[gomi["typeID"]] | |
# csvへ書き出し | |
with open("chiyoda_gomi.csv","w") as f: | |
header = ['gomi_name', 'gomi_type'] | |
writer = csv.DictWriter(f,header) | |
for r in list(gomi_dict.keys()): | |
row = {"gomi_name": r, "gomi_type": gomi_dict[r]} | |
writer.writerow(row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment