def export_str(strFileName):
import xlrd
import xlwt
import string
from xlutils.copy import copy
orgTab=xlrd.open_workbook(strFileName)
default=orgTab.sheets()[0]
workTab=copy(orgTab)
with open("build_text.txt", mode="r", encoding="utf-8") as file:
for line in file:
cell=line.split()
string_id.append(cell[3])
# add sheet for each language
for column in range(4,default.ncols-1):
language=default.cell_value(0,column)
ws=workTab.add_sheet(str(language))
ws.write(0,0,"ID")
ws.write(0,1,"Length")
ws.write(0,2,"English")
ws.write(0,3,str(language))
list_sheet.write(list_row,0,str(language))
list_row+=1
# Total word Count
list_sheet.write(list_row, 0, "Total Count")
isCn=0
ws_default=workTab.get_sheet(0)
for column in range(4,default.ncols-1):
ws=workTab.get_sheet(column)
k=1
for row in range(1,default.nrows):
if default.cell_value(row,column)=="":
for match_id in string_id:
if default.cell_value(row,0)==match_id:
ws_default.write(row,1,"used")
ws.write(k,0,default.cell_value(row,0))
ws.write(k,2,default.cell_value(row,3))
k+=1
ws.write(k, 0, "Total word count")
list_sheet.write(list_cnt, 1, k-1)
list_cnt+=1
workTab.save(strFileName)
print("export str.xls")
export_str("str.xls")