24 lines
801 B
Python
24 lines
801 B
Python
# 将 l3_scores.json 的 AI 预评分写回李克特评分表 Excel
|
|
import json
|
|
from openpyxl import load_workbook
|
|
|
|
XLSX = r"C:\Users\eeymoo\Documents\毕业论文\实验结果\L3修复建议_李克特评分表.xlsx"
|
|
scores = json.load(open("l3_scores.json", encoding="utf-8"))
|
|
|
|
wb = load_workbook(XLSX)
|
|
print("sheets:", wb.sheetnames)
|
|
ws = wb["打分表"] if "打分表" in wb.sheetnames else wb.active
|
|
|
|
# 表头在第 2 行;C 列 run_id、L 列评分、M 列备注
|
|
filled = 0
|
|
for row in ws.iter_rows(min_row=3):
|
|
run_id = row[2].value # C 列 run_id
|
|
if run_id in scores:
|
|
score, reason = scores[run_id]
|
|
row[11].value = score # L 列 评分(1-5)
|
|
row[12].value = reason # M 列 备注
|
|
filled += 1
|
|
|
|
wb.save(XLSX)
|
|
print(f"filled {filled} rows")
|