下面是我编写的代码,用于过滤文件夹内每个 excel 文件中的“新鲜度”表。但是每当我打开每个 excel 文件时,每个 excel 文件中的所有数据都已被代码删除。请建议任何其他方式进行相同的操作
数据集:-
代码:-
df_sold_to_list = pd.ExcelFile('C:/Users/ISLAMS/Downloads/Adhoc/Automation/VMI Scorecard/APS/All Sold to list.xlsx')
df_aps = pd.read_excel(df_sold_to_list, 'APS')
files_path = 'C:/Users/ISLAMS/Downloads/Adhoc/Automation/VMI Scorecard/APS/'
read_files = glob.glob(os.path.join(files_path,"*.xlsx"))
for files in read_files:
for i in range(len(df_aps)):
row_item = df_aps.loc[i, 'Sold To']
df = pd.ExcelFile(files)
df_freshness = pd.read_excel(df, 'Freshness')
df_freshness.loc[df_freshness['Sold To'] == row_item]
break