2 Star 0 Fork 2

刘煜/办公脚本

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
curriculum.py 1.10 KB
一键复制 编辑 原始数据 按行查看 历史
刘煜 提交于 2021-07-27 23:13 +08:00 . 使用固定文件名
import pandas as pd
import uuid,sys
#讲师名称(Excel中字段名)
name = "刘煜(西安)"
#导出课表的月份
month = "2021-6"
#输出文件名
output = name + month + '课程安排.ics'
if len(sys.argv) < 2:
print("请指定Excel文件")
sys.exit()
cal = pd.read_excel(sys.argv[1], sheet_name=0, skiprows=1)
#选择列
cal = cal[["讲师", name]].set_index('讲师')
courses = pd.Series(cal[name], index=cal.index)
#删除无安排的日期
courses = courses[courses.notnull()]
with open(output, 'w', encoding = 'utf-8') as f:
f.write("BEGIN:VCALENDAR\n")
f.write("PRODID:-//HQYJ//Curriculum//EN\n")
f.write("VERSION:2.0\n")
f.write("METHOD:PUBLISH\n")
#遍历指定月份的课程安排
for date, course in courses[month].items():
f.write("BEGIN:VEVENT\n")
f.write("DTSTART;VALUE=DATE:%s\n" % str(date.strftime("%Y%m%d")))
f.write("SUMMARY:%s\n" % course)
f.write("UID:%s\n" % str(uuid.uuid1()))
f.write("TRANSP:TRANSPARENT\n")
f.write("END:VEVENT\n")
f.write("END:VCALENDAR\n")
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tinytaro/office-script.git
git@gitee.com:tinytaro/office-script.git
tinytaro
office-script
办公脚本
master

搜索帮助