Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Python中读取特定工作表并附加文件_Python - Fatal编程技术网

在Python中读取特定工作表并附加文件

在Python中读取特定工作表并附加文件,python,Python,我在一个文件夹中有多个xlsx文件。我需要检查表名“vinf”。如果存在,则继续将其附加到python中的新文件中。我自己找到了答案 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 =

我在一个文件夹中有多个xlsx文件。我需要检查表名“vinf”。如果存在,则继续将其附加到python中的新文件中。

我自己找到了答案

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)
谢谢