Update app.py
Browse files
app.py
CHANGED
|
@@ -276,14 +276,23 @@ def is_valid_url(url):
|
|
| 276 |
|
| 277 |
return False
|
| 278 |
|
| 279 |
-
def parse_csv_file(
|
| 280 |
"""Parse CSV file and extract website URLs from column H (or auto-detect)"""
|
| 281 |
websites = []
|
| 282 |
debug_info = []
|
| 283 |
|
| 284 |
try:
|
| 285 |
-
#
|
| 286 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
|
| 288 |
# Parse CSV
|
| 289 |
csv_reader = csv.reader(io.StringIO(content))
|
|
|
|
| 276 |
|
| 277 |
return False
|
| 278 |
|
| 279 |
+
def parse_csv_file(file_obj):
|
| 280 |
"""Parse CSV file and extract website URLs from column H (or auto-detect)"""
|
| 281 |
websites = []
|
| 282 |
debug_info = []
|
| 283 |
|
| 284 |
try:
|
| 285 |
+
# Handle different file input types
|
| 286 |
+
if hasattr(file_obj, 'name'):
|
| 287 |
+
# This is a file path (NamedString from Gradio)
|
| 288 |
+
with open(file_obj.name, 'r', encoding='utf-8') as f:
|
| 289 |
+
content = f.read()
|
| 290 |
+
elif isinstance(file_obj, str):
|
| 291 |
+
# This is already a string
|
| 292 |
+
content = file_obj
|
| 293 |
+
else:
|
| 294 |
+
# This might be bytes
|
| 295 |
+
content = file_obj.decode('utf-8')
|
| 296 |
|
| 297 |
# Parse CSV
|
| 298 |
csv_reader = csv.reader(io.StringIO(content))
|