55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
# -*- coding: utf-8 -*-
|
||
|
|
|
||
|
|
import json
|
||
|
|
from collections import defaultdict
|
||
|
|
|
||
|
|
def extract_positions_by_batch():
|
||
|
|
# 读取土木水利岗位简历数据
|
||
|
|
with open('网页未导入数据/土木水利产业/土木水利岗位简历.json', 'r', encoding='utf-8') as f:
|
||
|
|
civil_positions_data = json.load(f)
|
||
|
|
|
||
|
|
# 按批次分类
|
||
|
|
batch_positions = {
|
||
|
|
"第一批次": [],
|
||
|
|
"第二批次": [],
|
||
|
|
"第三批次": []
|
||
|
|
}
|
||
|
|
|
||
|
|
# 提取岗位名称并按批次分类
|
||
|
|
for item in civil_positions_data:
|
||
|
|
position_name = item.get("岗位名称", "")
|
||
|
|
batch = item.get("批次", "")
|
||
|
|
|
||
|
|
if batch in batch_positions and position_name:
|
||
|
|
batch_positions[batch].append(position_name)
|
||
|
|
|
||
|
|
# 输出结果
|
||
|
|
print("土木水利岗位按批次分类:\n")
|
||
|
|
|
||
|
|
# 第一批次
|
||
|
|
print(f"第一批次 ({len(batch_positions['第一批次'])} 个岗位):")
|
||
|
|
for pos in batch_positions['第一批次']:
|
||
|
|
print(f" - {pos}")
|
||
|
|
|
||
|
|
# 第二批次
|
||
|
|
print(f"\n第二批次 ({len(batch_positions['第二批次'])} 个岗位):")
|
||
|
|
for pos in batch_positions['第二批次']:
|
||
|
|
print(f" - {pos}")
|
||
|
|
|
||
|
|
# 第三批次
|
||
|
|
print(f"\n第三批次 ({len(batch_positions['第三批次'])} 个岗位):")
|
||
|
|
for pos in batch_positions['第三批次']:
|
||
|
|
print(f" - {pos}")
|
||
|
|
|
||
|
|
# 生成JavaScript格式的输出
|
||
|
|
print("\n\n=== JavaScript格式输出 ===\n")
|
||
|
|
|
||
|
|
print("const initialBatchPositions = {")
|
||
|
|
print(f' batch1: {json.dumps(batch_positions["第一批次"], ensure_ascii=False, indent=4).replace(" ", " ")},')
|
||
|
|
print(f' batch2: {json.dumps(batch_positions["第二批次"], ensure_ascii=False, indent=4).replace(" ", " ")},')
|
||
|
|
print(f' batch3: {json.dumps(batch_positions["第三批次"], ensure_ascii=False, indent=4).replace(" ", " ")}')
|
||
|
|
print("};")
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
extract_positions_by_batch()
|