Initial commit: MSH System\n\n- msh_single_uniapp: Vue 2 + UniApp 前端(微信小程序/H5/App/支付宝小程序)\n- msh_crmeb_22: Spring Boot 2.2 后端(C端API/管理端/业务逻辑)\n- models-integration: AI服务集成(Coze/KieAI/腾讯ASR)\n- docs: 产品文档与设计稿
This commit is contained in:
39
models-integration/read_excel_correct.py
Normal file
39
models-integration/read_excel_correct.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import pandas as pd
|
||||
|
||||
# 读取Excel文件
|
||||
file_path = '/Users/a123/Documents/UthinkJava2025/xbb-api-demo/sql/名称代码对应表.xls'
|
||||
df = pd.read_excel(file_path)
|
||||
|
||||
# 清理列名中的特殊字符
|
||||
df.columns = [col.replace('\x00', '') for col in df.columns]
|
||||
|
||||
# 打印列名
|
||||
print("列名:")
|
||||
for i, col in enumerate(df.columns):
|
||||
print(f"{i+1}. {col}")
|
||||
|
||||
# 打印前几行数据
|
||||
print("\n前5行数据:")
|
||||
print(df.head())
|
||||
|
||||
# 构建替换映射数组
|
||||
name_code_map = []
|
||||
for index, row in df.iterrows():
|
||||
# 假设第一列是名称,第二列是代码
|
||||
if len(df.columns) >= 3: # 序号、名称、代码三列
|
||||
name = str(row.iloc[1]) if not pd.isna(row.iloc[1]) else '' # 名称在第二列
|
||||
code = str(row.iloc[2]) if not pd.isna(row.iloc[2]) else '' # 代码在第三列
|
||||
if name and code:
|
||||
name_code_map.append((name.strip(), code.strip()))
|
||||
|
||||
print("\n名称代码对应关系:")
|
||||
for name, code in name_code_map[:10]: # 只打印前10个
|
||||
print(f"{name} -> {code}")
|
||||
print(f"总共 {len(name_code_map)} 个映射关系")
|
||||
|
||||
# 生成Java代码
|
||||
print("\n生成的Java代码:")
|
||||
print("private static final String[][] NAME_CODE_MAP = {")
|
||||
for name, code in name_code_map:
|
||||
print(f' {{"{name}", "{code}"}},')
|
||||
print("};")
|
||||
Reference in New Issue
Block a user