Python处理Excel文件:
#只有一个Excel文件且该excel中多个sheet:
import pandas as pd
import os as los
import matplotlib.pyplot as mt
sheetnames = ['sheet1','Sheet2']
for sheet_name in sheetnames:
df = None
peoples=pd.read_excel('测试.xlsx',sheet_name=sheet_name)
print(peoples)
#Excel合并:读取多个excel的内容(汇总多个excel---每个excel只有一个工作薄有内容:以便查看姓名及身份证号):
# 导入模块
import os
import pandas as pd
def get_files(path):
fs = []
for root, dirs,files in os.walk(path):
for file in files:
fs.append(os.path.join(root,file))
return fs
def merge():
# 需要处理的文件放在:批量表所在文件夹路径(D:/Python/Test目录下)
files = get_files('./Test/')
arr = []
for i in files:
arr.append(pd.read_excel(i))
# 目标文件的路径(D:/Python目录