00.指定路径打开jupyter
anaconda prompt
输入想进入盘及文件
如 :
d:
cd test
最后输入:
jupyter notebook
1.python读取xlsx文件
# coding: utf-8
from pandas import read_excel
import pandas
df1=read_excel(r'E:\R\Store.xlsx',sheet_name='Shop')
df1.head()
2.python合并xlsx文件
# 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数据/"
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数据/"
excels = [read_excel(fname) for fname in os.listdir(path) if 'xls' in fname]
df = pd.concat(excels)
df.to_excel('D:/test/test数据/汇总.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/储值卡金额异动统计/11/2021-03.xlsx')
#df1.head()
time_start=time.time()
path="D:/test/test数据/aa/"
#path="E:/R/Data/储值卡金额异动统计/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数据/储值卡金额异动汇总.xlsx', index=False)
#path="D:/test/test数据/"
#excels = [read_excel(fname) for fname in os.listdir(path) if 'xls' in fname]
#df = pd.concat(excels)
#df.to_excel('D:/test/test数据/汇总.xlsx', index=False)
print("------完成------")
time_end=time.time()
print('time cost',time_end-time_start,'s')
df.head()