import xlrd
import xlwt
path = 'D:/桌面/公司信息/'
a = 'test1.xls'
b = 'test2.xls'
file = xlwt.Workbook(encoding='utf-8')
wtable = file.add_sheet('data')
data_a = xlrd.open_workbook(path + a)
table = data_a.sheets()[0]
nrowsa = table.nrows
lista = []
numa = 0
for i in range(2, nrowsa):
item = table.row_values(i, start_colx=0, end_colx=None)
# print(item)
lista.append(item[0])
data_b = xlrd.open_workbook(path + b)
table = data_b.sheets()[0]
nrowsb = table.nrows
numb = 0
for i in range(2, nrowsb):
item = table.row_values(i, start_colx=0, end_colx=None)
# print(item)
if item[0] in lista:
print(item[0])
else:
numb += 1
for i in range(0, len(item)):
print(numb, i, item[i])
wtable.write(numb, i, item[i])
file.save(path+'data.xlsx')
网友评论