安装操作环境:
安装:
python -m pip install jupyter notebook -i https://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install --upgrade pip -i https://pypi.douban.com/simple/
pip install --user pandas -i https://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install xlrd -i https://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip install openpyxl -i https://pypi.douban.com/simple/ --trusted-host pypi.douban.com
cd C:\Users\chair\AppData\Local\Programs\Python\Python38\Scripts
import pandas as pd
import os
data=pd.DataFrame()
dir="D:/nevwork/"
filenames=os.listdir(dir)
for name in filenames:
file=pd.ExcelFile("D:/nevwork/"+name)
for i in file.sheet_names;
if "日记账" in i
df=pd.read_excel("D:/nevwork/"+name,sheet_name=i,skiprows=4,usecols="C:F")
condition=df["月份"].str.startswith("2月")
s1=df[condition]
data=pd.concat([data,s1])
data.to_excel("D:/newwork/合并完成.xlsx")