# coding: utf-8
from pandas import read_excel
import pandas
import os
excels = [read_excel(fname) for fname in os.listdir('./') if 'xls' in fname]
df = pd.concat(excels)
df.to_excel('匯總.xlsx', index=False)
#垃圾堆
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os, sys
# 打開文件
path = "D:/test/test數(shù)據(jù)/"
dirs = os.listdir( path )
# 輸出所有文件和文件夾
for file in dirs:
print (file)
#合并版
# coding: utf-8
from pandas import read_excel
import pandas
import os
#df1=read_excel(r'E:\R\Store.xlsx',sheet_name='Shop')
#df1.head()
path="D:/test/test數(shù)據(jù)/"
excels = [read_excel(fname) for fname in os.listdir(path) if 'xls' in fname]
df = pd.concat(excels)
df.to_excel('D:/test/test數(shù)據(jù)/匯總.xlsx', index=False)
# coding: utf-8
from pandas import read_excel
import pandas as pd
import os
import time
#df=read_excel('E:/R/Data/儲(chǔ)值卡金額異動(dòng)統(tǒng)計(jì)/11/2021-03.xlsx')
#df1.head()
time_start=time.time()
path="D:/test/test數(shù)據(jù)/aa/"
#path="E:/R/Data/儲(chǔ)值卡金額異動(dòng)統(tǒng)計(jì)/11/"
excels = [read_excel(fname) for fname in os.listdir(path) if 'xls' in fname]
df = pd.concat(excels)
df.to_excel('D:/test/test數(shù)據(jù)/儲(chǔ)值卡金額異動(dòng)匯總.xlsx', index=False)
#path="D:/test/test數(shù)據(jù)/"
#excels = [read_excel(fname) for fname in os.listdir(path) if 'xls' in fname]
#df = pd.concat(excels)
#df.to_excel('D:/test/test數(shù)據(jù)/匯總.xlsx', index=False)
print("------完成------")
time_end=time.time()
print('time cost',time_end-time_start,'s')
df.head()