|
|
@@ -96,17 +96,23 @@ class UserImportService:
|
|
|
for index, row in df_data.iterrows():
|
|
|
row_num = index + 1 # 1-based row number for display
|
|
|
|
|
|
+ # Extract Data first to check for empty rows
|
|
|
+ mobile_col = mapping.get("mobile")
|
|
|
+ name_col = mapping.get("name")
|
|
|
+ en_name_col = mapping.get("english_name")
|
|
|
+
|
|
|
+ mobile = str(row[mobile_col]).strip() if mobile_col is not None and pd.notna(row[mobile_col]) else None
|
|
|
+ name = str(row[name_col]).strip() if name_col is not None and pd.notna(row[name_col]) else None
|
|
|
+ if name:
|
|
|
+ name = name.replace(" ", "")
|
|
|
+ en_name = str(row[en_name_col]).strip() if en_name_col is not None and pd.notna(row[en_name_col]) else None
|
|
|
+
|
|
|
+ # Skip empty rows (often generated by Excel at the end)
|
|
|
+ if not mobile and not name and not en_name:
|
|
|
+ continue
|
|
|
+
|
|
|
try:
|
|
|
with db.begin_nested():
|
|
|
- # 1. Extract Data
|
|
|
- mobile_col = mapping.get("mobile")
|
|
|
- name_col = mapping.get("name")
|
|
|
- en_name_col = mapping.get("english_name")
|
|
|
-
|
|
|
- mobile = str(row[mobile_col]).strip() if mobile_col is not None and pd.notna(row[mobile_col]) else None
|
|
|
- name = str(row[name_col]).strip() if name_col is not None and pd.notna(row[name_col]) else None
|
|
|
- en_name = str(row[en_name_col]).strip() if en_name_col is not None and pd.notna(row[en_name_col]) else None
|
|
|
-
|
|
|
if not mobile:
|
|
|
raise ValueError("Mobile is required")
|
|
|
|