Skip to content

Instantly share code, notes, and snippets.

@Omochin
Created February 27, 2017 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Omochin/8689ad962aaa08a0e4d492954549019b to your computer and use it in GitHub Desktop.
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に吐くスクリプト
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