테이블과 동일한 열을 비교하여 데이터 채우기
5288 단어 excel
import xlrd,xlwt
from tkinter import filedialog, messagebox
from xlutils.copy import copy#
path_z = filedialog.askopenfilenames(filetypes=[(" ", "xls")], title=" ")
path_f = filedialog.askopenfilenames(filetypes=[(" ", "xls")], title=" ")
wb= xlrd.open_workbook(path_z[0])
ws = wb.sheet_by_name(" ")
nwb=copy(wb)
nws=nwb.get_sheet(" ")
wb1 = xlrd.open_workbook(path_f[0])
ws1 = wb1.sheet_by_index(0)
for row in range(1,ws.nrows):
cell = ws.cell_value(row,1)
for row1 in range(1,ws1.nrows):
cell1 = ws1.cell_value(row1,4)
val1 = ws1.cell_value(row1,5)
if cell1 == cell:
nws.write(row,3,val1)
nwb.save(r"C:\Users\Administrator\Desktop\ \11-23\ \1.xls")