fix: The system reports an error when uploading an Excel file with null values

This commit is contained in:
junjun
2026-04-20 10:17:57 +08:00
committed by Junjun
parent d0fa42fcd6
commit 20632f8486
+4 -2
View File
@@ -35,7 +35,8 @@ def parse_excel_preview(save_path: str, max_rows: int = 10):
"fieldName": col,
"fieldType": infer_field_type(df[col].dtype)
})
preview_data = df.head(max_rows).to_dict(orient='records')
preview_df = df.head(max_rows).replace({pd.NA: None, float('nan'): None})
preview_data = preview_df.to_dict(orient='records')
sheets_data.append({
"sheetName": "Sheet1",
"fields": fields,
@@ -52,7 +53,8 @@ def parse_excel_preview(save_path: str, max_rows: int = 10):
"fieldName": col,
"fieldType": infer_field_type(df[col].dtype)
})
preview_data = df.head(max_rows).to_dict(orient='records')
preview_df = df.head(max_rows).replace({pd.NA: None, float('nan'): None})
preview_data = preview_df.to_dict(orient='records')
sheets_data.append({
"sheetName": sheet_name,
"fields": fields,