'''
比对表单1和表单2,若表单1 A列含有表单2 B列的字段,则标识表单1对应行
'''
import pandas as pd
import numpy as np
import datetime
if __name__=='__main__':
starttime=datetime.datetime.now()
sheet1=pd.read_excel('URL.xlsx',sheet_name='表单1') #读取表单1
sheet2=pd.read_excel('URL.xlsx',sheet_name='表单2') #读取表单2
d1=sheet2.iloc[:,B] #表单2需匹配到表单1的字段列
d2=np.unique(d1) #去重
table_row2=d2.shape[0] #表单2需匹配到表单1的字段,distinct个数,递归第二层数量
table_row1=sheet1.shape[0] #表单1的个数,递归第一层数量
for j in range(1,table_row1):
for i in range(0,table_row2-1):
if sheet1.iloc[j,A]==d2[i]: #判断A列是否包含表2 B列的字段
sheet1.iloc[j,D]=1 #若匹配到,改行D列数据为1,用于标识
break
sheet1.to_excel('URL.xlsx')
endtime=datetime.datetime.now()
print(endtime-starttime)
print("Done")