我在一个文件夹中有多个xlsx文件。我需要检查表格名称" vinf"。如果存在,则继续将其附加到python中的新文件中。
答案 0 :(得分:1)
我自己想通了。
path = r'C:/MY_FOLDER/WPP/December work/AM WPP ACCESS SOURCES/03-Cluster 3 OPCOs RVtool Reports - NEW/Y&R/Dec 2017' # use your path
allFiles = glob.glob(path + "/*.xlsx")
frame = pd.DataFrame()
list_ = []
for file_ in allFiles:
df = pd.read_excel(file_,sheetname = 'vinf')
list_.append(df)
frame = pd.concat(list_)
frame.to_excel('C:/MY_FOLDER/WPP/December work/AM WPP ACCESS SOURCES/03-Cluster 3 OPCOs RVtool Reports - NEW/Y&R/FINAL_OM_XLSX.xlsx',index = False)
由于