import xlrd
import xlwt
import os
l_p = []
l_t = []
def read_excel():
wb_pri = xlrd.open_workbook('verp.xlsx')
wb_tar = xlrd.open_workbook('vert.xlsx')
wb_result = xlwt.Workbook()
sheet_result = wb_result.add_sheet('result', cell_overwrite_ok=True)
result_i = 0
result_j = 0
for sheet_i in range(2, 21):
sheet_pri = wb_pri.sheet_by_index(sheet_i)
sheet_tar = wb_tar.sheet_by_index(sheet_i)
sheet_backup = wb_backup.get_sheet(sheet_i)
print(sheet_pri.name, sheet_tar.name)
l_p = sheet_pri.col_values(2)
l_t = sheet_tar.col_values(2)
tmp_pd = list(set(l_p).difference(set(l_t)))
tmp_td = list(set(l_t).difference(set(l_p)))
if result_i < result_j:
result_i = result_j
else:
result_j = result_i
for pd_i in tmp_pd:
result_i = result_i + 1
sheet_result.write(result_i, 0, sheet_pri.name)
sheet_result.write(result_i, 2, pd_i)
for td_i in tmp_td:
result_j = result_j + 1
sheet_result.write(result_j, 1, sheet_tar.name)
sheet_result.write(result_j, 3, td_i)
wb_result.save('result.xls')
if __name__ == '__main__':
read_excel()