import pandas as pd

new_file = "/root/.openclaw/media/inbound/â_¼ï_LV1-å_ç_å_è_åº_-ç¼_å_é_è_ç_è_é---23d539f8-33d6-4679-b9ae-91520114ae54.xlsx"
df_new = pd.read_excel(new_file)

print(f"定稿库总单词数：{len(df_new)}")
print("\n单元分布：")
units = df_new['占用情况'].dropna().unique()
units_sorted = sorted(units, key=lambda x: (int(x.split('-')[1][1:]) if x.startswith('S') else 999, int(x.split('-')[2][1:]) if len(x.split('-'))>2 else 999))
for unit in units_sorted:
    count = len(df_new[df_new['占用情况'] == unit])
    print(f"{unit}: {count}个")

# 统计上册（S0 + S1 U1-U6）和下册（S1 U7+）的数量
upper_count = 0
lower_count = 0
for idx, row in df_new.iterrows():
    unit = row['占用情况']
    if pd.isna(unit) or unit == '不常见':
        continue
    unit = unit.strip()
    if unit.startswith('S0-'):
        upper_count +=1
    elif unit.startswith('S1-U'):
        unit_num = int(unit.split('-')[1][1:])
        if unit_num <=6:
            upper_count +=1
        else:
            lower_count +=1

print(f"\n按单元统计：")
print(f"上册单词总数（S0 + S1 U1-U6）：{upper_count}")
print(f"下册单词总数（S1 U7+）：{lower_count}")
