美文网首页
xrld xlwt笔记

xrld xlwt笔记

作者: 周周周__ | 来源:发表于2020-05-09 15:01 被阅读0次
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')

相关文章

网友评论

      本文标题:xrld xlwt笔记

      本文链接:https://www.haomeiwen.com/subject/msyknhtx.html