ai_member_xiaoban/match_remaining.py
2026-03-14 08:00:01 +08:00

42 lines
1.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import pandas as pd
# 文件路径
table1_path = "/root/.openclaw/media/inbound/é_¾åº_æ_æ_å_è_ç³_æ_1.0---4d1d9fe3-1e36-4df1-baf6-d826fcf7a05e.xlsx"
table2_path = "/root/.openclaw/media/inbound/â_¼ï_LV1-å_ç_å_è_åº_-ç¼_å_é_è_ç_è_é---5b90d819-abf3-4882-8772-ed8f3e0b449f.xlsx" # 剩下的480行
output_path = "/root/.openclaw/workspace-xiaoban/匹配完成的LV1下册词汇表.xlsx"
# 读取表格
df1 = pd.read_excel(table1_path)
df2 = pd.read_excel(table2_path)
print(f"表一总条数:{len(df1)}")
print(f"待处理的下册表总条数:{len(df2)}")
# 创建映射
word_map = {}
for _, row in df1.iterrows():
word = str(row['单词']).strip()
word_map[word] = {
'难度D': row['难度D'],
'实现成本(T)': row['实现成本(T)'],
'单词系数': row['单词系数']
}
# 匹配字段
def get_value(word, col):
key = str(word).strip()
return word_map.get(key, {}).get(col, None)
df2['难度D'] = df2['单词'].apply(lambda x: get_value(x, '难度D'))
df2['实现成本(T)'] = df2['单词'].apply(lambda x: get_value(x, '实现成本(T)'))
df2['单词系数'] = df2['单词'].apply(lambda x: get_value(x, '单词系数'))
# 保存
df2.to_excel(output_path, index=False)
# 统计
match_count = df2['难度D'].notna().sum()
print(f"\n处理完成!结果已保存到:{output_path}")
print(f"成功匹配条数:{match_count}")
print(f"未匹配条数:{len(df2) - match_count}")