Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -225,12 +225,14 @@ def process_input(text_input, file):
|
|
| 225 |
file_name = file.name
|
| 226 |
|
| 227 |
if file_name.endswith('.txt'):
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
|
|
|
|
|
|
| 234 |
elif file_name.endswith('.csv'):
|
| 235 |
df = pd.read_csv(file)
|
| 236 |
comments += df.iloc[:, 0].dropna().astype(str).tolist()
|
|
|
|
| 225 |
file_name = file.name
|
| 226 |
|
| 227 |
if file_name.endswith('.txt'):
|
| 228 |
+
try:
|
| 229 |
+
content = file.read()
|
| 230 |
+
if isinstance(content, bytes):
|
| 231 |
+
content = content.decode('utf-8')
|
| 232 |
+
except UnicodeDecodeError:
|
| 233 |
+
content = file.read().decode('utf-8-sig')
|
| 234 |
+
comments += [line.strip() for line in content.splitlines() if line.strip()]
|
| 235 |
+
|
| 236 |
elif file_name.endswith('.csv'):
|
| 237 |
df = pd.read_csv(file)
|
| 238 |
comments += df.iloc[:, 0].dropna().astype(str).tolist()
|