56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
# -*- coding: utf-8 -*-
|
|||
|
|
|
|||
|
|
import json
|
|||
|
|
import os
|
|||
|
|
|
|||
|
|
def convert_energy_interview_status():
|
|||
|
|
"""
|
|||
|
|
将能源岗位面试状态.json转换为系统期望的格式
|
|||
|
|
"""
|
|||
|
|
|
|||
|
|
# 读取能源岗位面试状态.json
|
|||
|
|
energy_file = "网页未导入数据/能源产业/能源岗位面试状态.json"
|
|||
|
|
if not os.path.exists(energy_file):
|
|||
|
|
print(f"文件不存在: {energy_file}")
|
|||
|
|
return
|
|||
|
|
|
|||
|
|
with open(energy_file, 'r', encoding='utf-8') as f:
|
|||
|
|
energy_data = json.load(f)
|
|||
|
|
|
|||
|
|
# 转换数据格式
|
|||
|
|
converted_data = []
|
|||
|
|
|
|||
|
|
for item in energy_data:
|
|||
|
|
# 提取日期部分 (去掉时间部分)
|
|||
|
|
flow_time = item["流程时间"]
|
|||
|
|
if " " in flow_time:
|
|||
|
|
date_part = flow_time.split(" ")[0]
|
|||
|
|
else:
|
|||
|
|
date_part = flow_time
|
|||
|
|
|
|||
|
|
# 构建阶段日期字段 (格式: 流程类型:日期)
|
|||
|
|
stage_date = f"{item['岗位内推流程']}:{date_part}"
|
|||
|
|
|
|||
|
|
converted_item = {
|
|||
|
|
"查询岗位名称": item["查询岗位名称"],
|
|||
|
|
"阶段日期": stage_date,
|
|||
|
|
"面试状态": item["内容"]
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
converted_data.append(converted_item)
|
|||
|
|
|
|||
|
|
# 写入目标文件
|
|||
|
|
output_file = "src/data/interviewStatus.json"
|
|||
|
|
with open(output_file, 'w', encoding='utf-8') as f:
|
|||
|
|
json.dump(converted_data, f, ensure_ascii=False, indent=2)
|
|||
|
|
|
|||
|
|
print(f"成功转换 {len(converted_data)} 条面试状态数据到 {output_file}")
|
|||
|
|
|
|||
|
|
# 打印前几条数据供检查
|
|||
|
|
print("\n转换后的前3条数据:")
|
|||
|
|
for i, item in enumerate(converted_data[:3]):
|
|||
|
|
print(f"{i+1}. {item}")
|
|||
|
|
|
|||
|
|
if __name__ == "__main__":
|
|||
|
|
convert_energy_interview_status()
|