Spotter-VM/sahana/sahana-lang-csv.py
Disassembler 567443260c Add Czech translation for Sahana
Add a script to convert Sahana translation XLS to python format
2017-08-31 11:27:57 +02:00

27 lines
608 B
Python

#!/usr/bin/env python
import csv
dictionary = {}
with open('cz.csv', 'rb') as csvfile:
reader = csv.reader(csvfile, delimiter=',', quotechar='\'')
for line in reader:
dictionary[line[1]] = line[2]
with open('cz.py', 'wb') as langfile:
langfile.write(str(dictionary))
--
import xlrd
from pprint import pprint
dictionary = {}
sheet = xlrd.open_workbook('cz.xls').sheet_by_index(0)
for i in range(1, sheet.nrows):
row = sheet.row(i)
dictionary[row[1].value.encode('utf-8')] = row[2].value.encode('utf-8')
with open('cz.py', 'wb') as langfile:
pprint(dictionary, langfile)