Create a gist now

Instantly share code, notes, and snippets.

https://developers.eveonline.com/resource/resources > sde-xxxxxxxx-TRANQUILITY.zip > sde > fsd > typeIDs.yaml の名前部分を抽出してCSVに吐くスクリプト
import: TypeIDs.yaml
export: TypeIDs.csv
locales:
# - de
- en
# - fr
- ja
# - ru
# - zh
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