mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-10 10:16:55 +08:00
fix: improve error message when uploading Excel file with incorrect column count
This commit is contained in:
@@ -17,6 +17,7 @@ from apps.data_training.models.data_training_model import DataTrainingInfo
|
||||
from common.core.config import settings
|
||||
from common.core.deps import SessionDep, CurrentUser, Trans
|
||||
from common.utils.data_format import DataFormat
|
||||
from common.utils.excel import get_excel_column_count
|
||||
|
||||
router = APIRouter(tags=["DataTraining"], prefix="/system/data-training")
|
||||
|
||||
@@ -136,6 +137,9 @@ async def upload_excel(trans: Trans, current_user: CurrentUser, file: UploadFile
|
||||
|
||||
for sheet_name in sheet_names:
|
||||
|
||||
if get_excel_column_count(save_path, sheet_name) < len(use_cols):
|
||||
raise Exception(trans("i18n_excel_import.col_num_not_match"))
|
||||
|
||||
df = pd.read_excel(
|
||||
save_path,
|
||||
sheet_name=sheet_name,
|
||||
|
||||
@@ -17,6 +17,7 @@ from apps.terminology.models.terminology_model import TerminologyInfo
|
||||
from common.core.config import settings
|
||||
from common.core.deps import SessionDep, CurrentUser, Trans
|
||||
from common.utils.data_format import DataFormat
|
||||
from common.utils.excel import get_excel_column_count
|
||||
|
||||
router = APIRouter(tags=["Terminology"], prefix="/system/terminology")
|
||||
|
||||
@@ -133,6 +134,9 @@ async def upload_excel(trans: Trans, current_user: CurrentUser, file: UploadFile
|
||||
|
||||
for sheet_name in sheet_names:
|
||||
|
||||
if get_excel_column_count(save_path, sheet_name) < len(use_cols):
|
||||
raise Exception(trans("i18n_excel_import.col_num_not_match"))
|
||||
|
||||
df = pd.read_excel(
|
||||
save_path,
|
||||
sheet_name=sheet_name,
|
||||
|
||||
Reference in New Issue
Block a user