Files
online_sys/frontend_财经商贸/extract_resume_data.py

62 lines
2.3 KiB
Python
Raw Permalink Normal View History

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import os
def extract_position_data(position_names):
"""从JSON文件中提取指定岗位的数据"""
result = {}
# 读取所有part文件
for i in range(1, 4):
file_path = f'/Users/apple/Documents/cursor/教务系统/frontend/网页未导入数据/文旅产业/个人简历内容_part{i}.json'
try:
with open(file_path, 'r', encoding='utf-8') as f:
data = json.load(f)
for item in data:
position = item.get('❌岗位名称查询', '')
if position in position_names:
result[position] = item
print(f"找到: {position} in part{i}")
except Exception as e:
print(f"Error reading part{i}: {e}")
# 也读取主文件
main_file = '/Users/apple/Documents/cursor/教务系统/frontend/网页未导入数据/文旅产业/个人简历内容.json'
try:
with open(main_file, 'r', encoding='utf-8') as f:
data = json.load(f)
for item in data:
position = item.get('❌岗位名称查询', '')
if position in position_names and position not in result:
result[position] = item
print(f"找到: {position} in main file")
except Exception as e:
print(f"Error reading main file: {e}")
return result
# 需要提取的岗位
positions_to_extract = [
'露营地运营专员',
'文创产品设计师', '文创产品策划师', '文创产品设计师助理',
'品牌策划运营专员', '品牌公关', '品牌推广专员',
'ip运营', 'IP运营总监助理', '品牌公关管培生'
]
# 提取数据
extracted_data = extract_position_data(positions_to_extract)
# 保存提取的数据
output_file = '/Users/apple/Documents/cursor/教务系统/frontend/extracted_resume_data.json'
with open(output_file, 'w', encoding='utf-8') as f:
json.dump(extracted_data, f, ensure_ascii=False, indent=2)
print(f"\n成功提取 {len(extracted_data)} 个岗位的数据")
print(f"已保存到: {output_file}")
# 显示缺失的岗位
missing = set(positions_to_extract) - set(extracted_data.keys())
if missing:
print(f"\n未找到的岗位: {missing}")