Skip to content

Commit

Permalink
feat 新增日志记录和提交者汇总
Browse files Browse the repository at this point in the history
  • Loading branch information
W1ndys committed Jan 30, 2025
1 parent 5a5e484 commit efa3b68
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions Easy-QFNU-Tools/Excel2md/AddNewData.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ def process_data(excel_file, markdown_dir):
df.columns = ["course", "teacher", "district", "year", "description", "submitter"]

rows_to_delete = []
unmatched_rows = set() # 使用集合来存储未匹配的行
unmatched_rows = set()

# 新增:用于记录更新日志和提交者
update_log = []
submitters = set()

# 遍历markdown文件
for filename in os.listdir(markdown_dir):
Expand Down Expand Up @@ -113,11 +117,17 @@ def process_data(excel_file, markdown_dir):

# 标记要删除的行
rows_to_delete.append(index)
# 如果之前被标记为未匹配,现在移除
unmatched_rows.discard(index)
content_modified = True

# 新增:记录更新日志和提交者
update_log.append(
f"【{course}】-【{district}】-【{teacher}】-【{row['year']}】"
)
submitters.add(row["submitter"])

print(
f"✅ 成功添加: {course} - {district} - {teacher} - {row['submitter']}"
f"✅ 成功添加: {course}】-【{district}】-【{teacher}】-【{row['submitter']}"
)
else:
# 只有当这行数据还没有被成功处理时,才标记为未匹配
Expand Down Expand Up @@ -147,6 +157,18 @@ def process_data(excel_file, markdown_dir):
print(f"- 未能匹配:{len(unmatched_rows)} 条数据")
print(f"- 总数据量:{len(df) + len(rows_to_delete)} 条数据")

# 新增:生成更新日志文件
if update_log:
with open("update_log.txt", "a", encoding="utf-8") as f:
f.write("\n".join(update_log) + "\n")

with open("submitters.txt", "a", encoding="utf-8") as f:
f.write(", ".join(sorted(submitters)) + "\n")

print("\n📝 更新日志已生成")
print(f"- 更新条目:{len(update_log)} 条")
print(f"- 提交人数:{len(submitters)} 人")


# 使用示例
process_data("data.xlsx", "example")

0 comments on commit efa3b68

Please sign in to comment.