Created
February 27, 2017 10:38
-
-
Save Omochin/8689ad962aaa08a0e4d492954549019b to your computer and use it in GitHub Desktop.
https://developers.eveonline.com/resource/resources > sde-xxxxxxxx-TRANQUILITY.zip > sde > fsd > typeIDs.yaml の名前部分を抽出してCSVに吐くスクリプト
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
import: TypeIDs.yaml | |
export: TypeIDs.csv | |
locales: | |
# - de | |
- en | |
# - fr | |
- ja | |
# - ru | |
# - zh |
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
import sys | |
import codecs | |
import yaml | |
import csv | |
from collections import OrderedDict | |
with open('config.yaml') as f: | |
config = yaml.load(f) | |
print(config['locales']) | |
yaml.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, | |
lambda loader, node: OrderedDict(loader.construct_pairs(node))) | |
with codecs.open(config['import'], 'r', 'utf-8') as f: | |
data = yaml.load(f) | |
rows = [] | |
for i, items in data.items(): | |
column = [i] | |
for locale in config['locales']: | |
try: | |
column.append(items['name'][locale]) | |
except: | |
print(i, sys.exc_info()) | |
rows.append(column) | |
with codecs.open(config['export'], 'w', 'utf-8') as f: | |
writer = csv.writer(f, lineterminator='\n') | |
writer.writerows(rows) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment