上传文件至 kg_lab_6.13
6.27 更新‘其他费用’映射冗余修正;更新多项指标映射变量冗余修正
This commit is contained in:
@@ -365,6 +365,18 @@ def parse_indicator_string_to_json(indicator_str: str, output_path: str = "outpu
|
||||
# 解析为 JSON 对象
|
||||
result = json.loads(indicator_str)
|
||||
|
||||
# 过滤
|
||||
for item in result:
|
||||
mapping = item.get("指标描述", {}).get("指标映射")
|
||||
if isinstance(mapping, str):
|
||||
if "【工程费用】" in mapping:
|
||||
cleaned = re.sub(r"@.*?\.", "", mapping)
|
||||
item["指标描述"]["指标映射"] = cleaned
|
||||
elif isinstance(mapping, list):
|
||||
first_elem = mapping[0]
|
||||
if first_elem.startswith("(") and first_elem.endswith(")"):
|
||||
del mapping[0]
|
||||
|
||||
# 保存为 JSON 文件
|
||||
with open(output_path, 'w', encoding='utf-8') as f:
|
||||
json.dump(result, f, ensure_ascii=False, indent=2)
|
||||
|
||||
Reference in New Issue
Block a user