78 lines
2.6 KiB
Python
78 lines
2.6 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
# -*- coding: utf-8 -*-
|
||
|
|
"""
|
||
|
|
替换日历课程数据
|
||
|
|
将能源课程日历数据替换到intelligentManufacturingCalendar.json
|
||
|
|
"""
|
||
|
|
|
||
|
|
import json
|
||
|
|
import shutil
|
||
|
|
from datetime import datetime
|
||
|
|
|
||
|
|
def main():
|
||
|
|
# 源文件和目标文件
|
||
|
|
source_path = '网页未导入数据/能源产业/能源课程日历.json'
|
||
|
|
target_path = 'src/data/intelligentManufacturingCalendar.json'
|
||
|
|
|
||
|
|
# 创建备份
|
||
|
|
backup_path = f'{target_path}.backup_{datetime.now().strftime("%Y%m%d_%H%M%S")}'
|
||
|
|
|
||
|
|
print(f"读取能源课程日历数据: {source_path}")
|
||
|
|
with open(source_path, 'r', encoding='utf-8') as f:
|
||
|
|
energy_calendar_data = json.load(f)
|
||
|
|
|
||
|
|
print(f"共读取到 {len(energy_calendar_data)} 条日历数据")
|
||
|
|
|
||
|
|
# 备份原文件
|
||
|
|
print(f"备份原文件到: {backup_path}")
|
||
|
|
shutil.copy2(target_path, backup_path)
|
||
|
|
|
||
|
|
# 写入新数据
|
||
|
|
print(f"写入能源日历数据到: {target_path}")
|
||
|
|
with open(target_path, 'w', encoding='utf-8') as f:
|
||
|
|
json.dump(energy_calendar_data, f, ensure_ascii=False, indent=2)
|
||
|
|
|
||
|
|
print("✅ 日历数据替换完成!")
|
||
|
|
print(f"- 原文件已备份: {backup_path}")
|
||
|
|
print(f"- 新数据已写入: {target_path}")
|
||
|
|
print(f"- 共替换 {len(energy_calendar_data)} 条日历记录")
|
||
|
|
|
||
|
|
# 统计课程类型
|
||
|
|
course_count = {
|
||
|
|
"公共课": 0,
|
||
|
|
"个人课程": 0,
|
||
|
|
"企业高管公开课": 0,
|
||
|
|
"1V1规划": 0,
|
||
|
|
"模拟面试": 0
|
||
|
|
}
|
||
|
|
|
||
|
|
for record in energy_calendar_data:
|
||
|
|
if record.get("公共课"):
|
||
|
|
course_count["公共课"] += 1
|
||
|
|
if record.get("个人课程表"):
|
||
|
|
course_count["个人课程"] += 1
|
||
|
|
if record.get("企业高管公开课"):
|
||
|
|
course_count["企业高管公开课"] += 1
|
||
|
|
if record.get("1V1 规划阶段"):
|
||
|
|
course_count["1V1规划"] += 1
|
||
|
|
if record.get("模拟面试实战练习阶段"):
|
||
|
|
course_count["模拟面试"] += 1
|
||
|
|
|
||
|
|
print("\n📊 课程类型统计:")
|
||
|
|
for type_name, count in course_count.items():
|
||
|
|
if count > 0:
|
||
|
|
print(f" - {type_name}: {count} 条")
|
||
|
|
|
||
|
|
# 显示前3个有课程的日期
|
||
|
|
print("\n📅 示例日期:")
|
||
|
|
sample_count = 0
|
||
|
|
for record in energy_calendar_data:
|
||
|
|
if record.get("上课状态") != "休息" and sample_count < 3:
|
||
|
|
date = record.get("日期", "")
|
||
|
|
course = record.get("公共课") or record.get("个人课程表") or record.get("企业高管公开课") or ""
|
||
|
|
if course:
|
||
|
|
print(f" {date}: {course[:30]}...")
|
||
|
|
sample_count += 1
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|