Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
f2514c2
1
Parent(s):
2fdc09f
lfg
Browse files- src/routes/session_routes.py +6 -16
src/routes/session_routes.py
CHANGED
|
@@ -153,11 +153,9 @@ async def upload_excel(
|
|
| 153 |
continue
|
| 154 |
|
| 155 |
# Register each sheet in DuckDB with a clean table name
|
| 156 |
-
clean_sheet_name = sheet_name
|
| 157 |
# Check if the clean_sheet_name is a safe Python variable name; if not, append a random int
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
clean_sheet_name = f"{clean_sheet_name}_{random.randint(1000, 9999)}"
|
| 161 |
# First drop the table if it exists
|
| 162 |
|
| 163 |
|
|
@@ -237,10 +235,7 @@ def clean_dataset_name(name: str) -> str:
|
|
| 237 |
if not re.match(r'^[a-zA-Z_]', name):
|
| 238 |
name = f"dataset_{name}"
|
| 239 |
|
| 240 |
-
|
| 241 |
-
if not is_safe_variable_name(name):
|
| 242 |
-
import random
|
| 243 |
-
name = f"{name}_{random.randint(1000, 9999)}"
|
| 244 |
|
| 245 |
return name
|
| 246 |
@router.post("/upload_dataframe")
|
|
@@ -282,9 +277,7 @@ async def upload_dataframe(
|
|
| 282 |
name = name[:30]
|
| 283 |
|
| 284 |
# Ensure it's a safe Python identifier
|
| 285 |
-
|
| 286 |
-
import random
|
| 287 |
-
name = f"{name}_{random.randint(1000, 9999)}"
|
| 288 |
|
| 289 |
# Read and process the CSV file
|
| 290 |
content = await file.read()
|
|
@@ -869,13 +862,10 @@ async def preview_csv_upload(
|
|
| 869 |
name = file.filename.replace('.csv', '').replace(' ', '_').lower().strip()
|
| 870 |
|
| 871 |
# Validate name length and create safe variable name
|
| 872 |
-
|
| 873 |
-
name = name[:30]
|
| 874 |
|
| 875 |
# Ensure it's a safe Python identifier
|
| 876 |
-
|
| 877 |
-
import random
|
| 878 |
-
name = f"{name}_{random.randint(1000, 9999)}"
|
| 879 |
|
| 880 |
# Format the description
|
| 881 |
desc = f" exact_python_name: `{name}` Dataset: {file.filename}"
|
|
|
|
| 153 |
continue
|
| 154 |
|
| 155 |
# Register each sheet in DuckDB with a clean table name
|
| 156 |
+
clean_sheet_name = clean_dataset_name(sheet_name)
|
| 157 |
# Check if the clean_sheet_name is a safe Python variable name; if not, append a random int
|
| 158 |
+
|
|
|
|
|
|
|
| 159 |
# First drop the table if it exists
|
| 160 |
|
| 161 |
|
|
|
|
| 235 |
if not re.match(r'^[a-zA-Z_]', name):
|
| 236 |
name = f"dataset_{name}"
|
| 237 |
|
| 238 |
+
|
|
|
|
|
|
|
|
|
|
| 239 |
|
| 240 |
return name
|
| 241 |
@router.post("/upload_dataframe")
|
|
|
|
| 277 |
name = name[:30]
|
| 278 |
|
| 279 |
# Ensure it's a safe Python identifier
|
| 280 |
+
|
|
|
|
|
|
|
| 281 |
|
| 282 |
# Read and process the CSV file
|
| 283 |
content = await file.read()
|
|
|
|
| 862 |
name = file.filename.replace('.csv', '').replace(' ', '_').lower().strip()
|
| 863 |
|
| 864 |
# Validate name length and create safe variable name
|
| 865 |
+
name = clean_dataset_name(name)
|
|
|
|
| 866 |
|
| 867 |
# Ensure it's a safe Python identifier
|
| 868 |
+
|
|
|
|
|
|
|
| 869 |
|
| 870 |
# Format the description
|
| 871 |
desc = f" exact_python_name: `{name}` Dataset: {file.filename}"
|