办公(Python处理Excel文件)
2022/2/11 11:16:15
本文主要是介绍办公(Python处理Excel文件),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
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目录
这篇关于办公(Python处理Excel文件)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-08有遇到过吗?同样的规则 Excel 中 比Python 结果大
- 2024-03-30开始python成长之路
- 2024-03-29python optparse
- 2024-03-29python map 函数
- 2024-03-20invalid format specifier python
- 2024-03-18pool.map python
- 2024-03-18threads in python
- 2024-03-14python Ai 应用开发基础训练,字符串,字典,文件
- 2024-03-13id3 algorithm python
- 2024-03-13sum array elements python