python自动excel查询系统
我知道这是很多代码,有很多事情要做,但我真的卡住了,不知道如何继续后,我得到的功能,该程序可以匹配相同的文件。我很确定您知道如何从excel中查找。这个程序基本上也是这样。我试图评论出重要的部分,希望你能给我一些帮助,我可以继续这个项目。多谢各位python自动excel查询系统,python,excel,pandas,Python,Excel,Pandas,我知道这是很多代码,有很多事情要做,但我真的卡住了,不知道如何继续后,我得到的功能,该程序可以匹配相同的文件。我很确定您知道如何从excel中查找。这个程序基本上也是这样。我试图评论出重要的部分,希望你能给我一些帮助,我可以继续这个项目。多谢各位 import pandas as pd import xlrd File1 = pd.read_excel("Excel_test.xlsx", usecols=[0], header=None, index=False) #the two exce
import pandas as pd
import xlrd
File1 = pd.read_excel("Excel_test.xlsx", usecols=[0], header=None, index=False) #the two excel files with the columns that should be compared
File2 = pd.read_excel("Excel_test02.xlsx", usecols=[0], header=None, index=False)
fullFile1 = pd.read_excel("Excel_test.xlsx", header=None, index=False)#the full excel files
fullFile2 = pd.read_excel("Excel_test02.xlsx", header=None, index=False)
i = 0
writer = pd.ExcelWriter("output.xlsx")
def loadingTime(): #just a loader that shows the percentage of the matching process
global i
loading = (i / len(File1)) * 100
loading = round(loading, 2)
print(str(loading) + "%/100%")
def matcher():
global i
while(i < len(File1)):#goes in column that should be compared and goes on higher if there is a match found in second file
for o in range(len(File2)):#runs through the column in second file
matching = File1.iloc[i].str.lower() == File2.iloc[o].str.lower() #matches the column contents of the two files
if matching.bool() == True:
print("Match")
"""
df.append(File1.iloc[i])#the whole row of the matched column should be appended in Dataframe with the arrangement of excel file
df.append(File2.iloc[o])#the whole row of the matched column should be appended in Dataframe with the arrangement of excel file
"""
i += 1
matcher()
df.to_excel(writer, "Sheet")
writer.save() #After the two files have been compared to each other, now a file containing both excel contents and is also arranged correctly
将熊猫作为pd导入
导入xlrd
File1=pd.read_excel(“excel_test.xlsx”,usecols=[0],header=None,index=False)#两个excel文件以及应比较的列
File2=pd.read\u excel(“excel\u test02.xlsx”,usecols=[0],header=None,index=False)
fullFile1=pd.read_excel(“excel_test.xlsx”,header=None,index=False)#完整的excel文件
fullFile2=pd.read\u excel(“excel\u test02.xlsx”,header=None,index=False)
i=0
writer=pd.ExcelWriter(“output.xlsx”)
def loadingTime():#只是一个显示匹配进程百分比的加载程序
全球i
加载=(i/len(File1))*100
加载=圆形(加载,2)
打印(str(加载)+“%/100%”)
def matcher():
全球i
while(i
是否尝试比较两个不同Excel文件中的两列,如果两个文件中的两个单元格匹配,则将file1和file2中的两行追加到新文件中?是的!这就是它的工作原理。