Fix off-by-one error in sahana-lang-csv.py and make it executable

This commit is contained in:
Disassembler 2017-09-11 10:47:42 +02:00
parent 712c3dfeff
commit a112f8a80d

4
sahana/sahana-lang-csv.py Normal file → Executable file
View File

@ -15,12 +15,12 @@ basename, extension = os.path.splitext(sys.argv[1].lower())
translations = {} translations = {}
if extension == '.csv': if extension == '.csv':
with open(sys.argv[0], 'rb') as csvfile: with open(sys.argv[1], 'rb') as csvfile:
reader = csv.reader(csvfile, delimiter=',', quotechar='\'') reader = csv.reader(csvfile, delimiter=',', quotechar='\'')
for line in reader: for line in reader:
translations[line[1].encode('utf-8')] = line[2].encode('utf-8') translations[line[1].encode('utf-8')] = line[2].encode('utf-8')
elif extension == '.xls': elif extension == '.xls':
sheet = xlrd.open_workbook(sys.argv[0]).sheet_by_index(0) sheet = xlrd.open_workbook(sys.argv[1]).sheet_by_index(0)
for i in range(1, sheet.nrows): for i in range(1, sheet.nrows):
row = sheet.row(i) row = sheet.row(i)
translations[row[1].value.encode('utf-8')] = row[2].value.encode('utf-8') translations[row[1].value.encode('utf-8')] = row[2].value.encode('utf-8')