import tkinter as tk
from tkinter import filedialog
import numpy as np
import pandas as pd
# 实例化
root = tk.Tk()
root.withdraw()
# 获取文件夹路径
f_path = filedialog.askopenfilename()
print('\n获取的文件地址:', f_path)
# 读取选择文件
df = pd.DataFrame(pd.read_excel(f_path))
# 获取文件夹路径
f_path1 = filedialog.askopenfilename()
print('\n获取的文件地址:', f_path1)
# 读取选择文件
df1 = pd.DataFrame(pd.read_excel(f_path1))
print('增加统计')
for i in df.iterrows():
#print('first:',df.loc[i[0], 'file path'])
flag = 0
for j in df1.iterrows():
#print('scend:',df1.loc[j[0], 'file path'])
if df.loc[i[0],'file path'] == df1.loc[j[0],'file path']:
if df.loc[i[0], 'nbnc line'] != df1.loc[j[0], 'nbnc line']:
print(df.loc[i[0], 'file path'], df.loc[i[0], 'nbnc line'] - df1.loc[j[0], 'nbnc line'])
flag = 1
if flag == 0:
print(df.loc[i[0], 'file path'], df.loc[i[0], 'nbnc line'])
print('删除统计')
for i in df1.iterrows():
#print('first:',df.loc[i[0], 'file path'])
flag = 0
for j in df.iterrows():
#print('scend:',df1.loc[j[0], 'file path'])
if df1.loc[i[0],'file path'] == df.loc[j[0],'file path']:
#print(df.loc[i[0], 'file path'], df.loc[i[0], 'nbnc line'] - df1.loc[j[0], 'nbnc line'])
#print(df.loc[i[0], 'nbnc line'])
#print(df1.loc[j[0], 'nbnc line'])
#print('-----------------------')
flag = 1
if flag == 0:
print(df1.loc[i[0], 'file path'], df1.loc[i[0], 'nbnc line'])