把一个文件夹下的多个excel文件合并到同一个excel的一个sheet里

#!/usr/bin/python

# -*- coding: UTF-8 -*-

import pandas as pd
import os

if __name__ == '__main__':
    Folder_Path = 'c:\data1'

    os.chdir(Folder_Path)
    file_list = os.listdir()

    dfs = []
    for item in file_list:
        dfs.append(pd.read_excel(Folder_Path + '\\' + item))

    df = pd.concat(dfs, sort=False)
    df.to_excel('c:\data1\out.xlsx', index=False)

 

posted @ 2019-03-21 11:36  东宫得臣  阅读(1063)  评论(0编辑  收藏  举报