Excel 数据对比

此函数实现的需求:
两张 Excel 表,分别得到两张表的相似两列数据,并将两列相似数据进行对比,最后提取出数据中不同项,并打印出不同项结果。


import ubpa.iexcel as iexcel

# 将两排数据中相同的人名和编号打印出来 
def compare_data():
    data_hr = []
    data_oil = []
    # excel_1
    line_ab = iexcel.read_col(path='file_path and parameters')
    line_ac = iexcel.read_col(path='file_path and parameters')    
    # put data in tuple
    for x in range(len(line_ab)):
        data_hr.append((int(line_ab[x]), line_ac[x]))
    # excel_2
    line_ea = iexcel.read_col(path='file_path and parameters')
    line_eb = iexcel.read_col(path='file_path and parameters')    
    for y in range(len(line_ea)):
        data_oil.append((int(line_ea[y]), line_eb[y]))
        
    for x in data_hr:
        for y in data_oil:
            if x == y:
                print(y)