python-自动化篇-办公-excel-实例应用(一维转二维)

文章目录

准备

放根目录

代码

python 复制代码
import openpyxl
wb=openpyxl.load_workbook('业绩表.xlsx')
if not '二维表' in wb.sheetnames:
    nws=wb.create_sheet('二维表')
    ws=wb.worksheets[0]
    rngs=list(ws.values)[1:]
    mm=list({m.value:'' for m in ws['b'][1:]})
    name=list({m.value:'' for m in ws['a'][1:]})
    nws.append(['姓名']+mm)
    for n in name:
        l=[(n,m) for m in mm]
        nws.append([n]+[list(filter(lambda r:t[0]==r[0] and t[1]==r[1],rngs))[0][2] for t in l])
    wb.save('业绩表.xlsx')

效果

相关推荐
DeniuHe12 小时前
sklearn 中所有交叉验证数据集划分方式完整总结
人工智能·python·sklearn
DeniuHe12 小时前
sklearn中不同交叉验证方法的场景适配
人工智能·python·sklearn
隐于花海,等待花开13 小时前
16.Python 常用第三方库概览 深度解析
python
我材不敲代码13 小时前
Python 函数核心:位置参数与关键字参数详解
java·前端·python
风落无尘13 小时前
第十一章《对齐与安全》 完整学习资料
python·安全·机器学习
Kratzdisteln13 小时前
【无标题】
前端·python
hakesashou13 小时前
python文件操作需要导入模块吗
python
wuxinyan12313 小时前
工业级大模型学习之路029:解决双智能体调用数据库报错问题
数据库·人工智能·python·学习·智能体
志栋智能13 小时前
超越监控:超自动化巡检提供的主动价值
运维·网络·人工智能·自动化
SunnyDays101113 小时前
Python操作Excel批注:从基础添加到高级自定义的完整指南
开发语言·python·excel