Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1305,13 +1305,13 @@ def process_examples(file_name):
|
|
| 1305 |
|
| 1306 |
|
| 1307 |
def clean_and_convert(cell):
|
| 1308 |
-
if isinstance(cell
|
| 1309 |
-
cell
|
| 1310 |
try:
|
| 1311 |
-
float_val = float(cell
|
| 1312 |
-
|
| 1313 |
except (ValueError, TypeError):
|
| 1314 |
-
|
| 1315 |
|
| 1316 |
def clean_excel_file(file_path):
|
| 1317 |
logger.info("Cleaning file...")
|
|
@@ -1332,7 +1332,7 @@ def clean_excel_file(file_path):
|
|
| 1332 |
# Iterate through all cells in the current sheet and clean the data
|
| 1333 |
for row in worksheet.iter_rows():
|
| 1334 |
for cell in row:
|
| 1335 |
-
clean_and_convert(cell)
|
| 1336 |
|
| 1337 |
# Save the cleaned file to the temporary path
|
| 1338 |
workbook.save(temp_file_path)
|
|
|
|
| 1305 |
|
| 1306 |
|
| 1307 |
def clean_and_convert(cell):
|
| 1308 |
+
if isinstance(cell, str): # Check if cell value is a string
|
| 1309 |
+
cell = cell.replace("\t", "")
|
| 1310 |
try:
|
| 1311 |
+
float_val = float(cell)
|
| 1312 |
+
return float_val
|
| 1313 |
except (ValueError, TypeError):
|
| 1314 |
+
return cell
|
| 1315 |
|
| 1316 |
def clean_excel_file(file_path):
|
| 1317 |
logger.info("Cleaning file...")
|
|
|
|
| 1332 |
# Iterate through all cells in the current sheet and clean the data
|
| 1333 |
for row in worksheet.iter_rows():
|
| 1334 |
for cell in row:
|
| 1335 |
+
cell.value = clean_and_convert(cell.value)
|
| 1336 |
|
| 1337 |
# Save the cleaned file to the temporary path
|
| 1338 |
workbook.save(temp_file_path)
|