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')

效果

相关推荐
YJlio6 小时前
1.7 通过 Sysinternals Live 在线运行工具:不下载也能用的“云端工具箱”
c语言·网络·python·数码相机·ios·django·iphone
l1t6 小时前
在wsl的python 3.14.3容器中使用databend包
开发语言·数据库·python·databend
2601_949146536 小时前
Shell语音通知接口使用指南:运维自动化中的语音告警集成方案
运维·自动化
0思必得06 小时前
[Web自动化] Selenium无头模式
前端·爬虫·selenium·自动化·web自动化
山塘小鱼儿7 小时前
本地Ollama+Agent+LangGraph+LangSmith运行
python·langchain·ollama·langgraph·langsimth
码说AI7 小时前
python快速绘制走势图对比曲线
开发语言·python
Gofarlic_OMS7 小时前
科学计算领域MATLAB许可证管理工具对比推荐
运维·开发语言·算法·matlab·自动化
AI_56788 小时前
Excel数据透视表提速:Power Query预处理百万数据
数据库·excel
dixiuapp8 小时前
智能工单系统如何选,实现自动化与预测性维护
运维·自动化