27 lines
608 B
Python
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)
|