Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -120,13 +120,12 @@ def _pick_text_column(df: pd.DataFrame) -> str | None:
|
|
| 120 |
|
| 121 |
|
| 122 |
def _list_text_columns(df: pd.DataFrame) -> list[str]:
|
| 123 |
-
"""
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
return text_cols
|
| 130 |
|
| 131 |
|
| 132 |
def _set_from_env_or_secrets(key: str):
|
|
@@ -486,6 +485,12 @@ if CSV_PATH is None:
|
|
| 486 |
@st.cache_data
|
| 487 |
def get_text_columns(csv_path: str) -> list[str]:
|
| 488 |
df_sample = pd.read_csv(csv_path, nrows=2000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 489 |
return _list_text_columns(df_sample)
|
| 490 |
|
| 491 |
|
|
|
|
| 120 |
|
| 121 |
|
| 122 |
def _list_text_columns(df: pd.DataFrame) -> list[str]:
|
| 123 |
+
"""
|
| 124 |
+
Return all columns; we’ll cast the chosen one to string later.
|
| 125 |
+
This makes the selector work with any column name / dtype.
|
| 126 |
+
"""
|
| 127 |
+
return list(df.columns)
|
| 128 |
+
|
|
|
|
| 129 |
|
| 130 |
|
| 131 |
def _set_from_env_or_secrets(key: str):
|
|
|
|
| 485 |
@st.cache_data
|
| 486 |
def get_text_columns(csv_path: str) -> list[str]:
|
| 487 |
df_sample = pd.read_csv(csv_path, nrows=2000)
|
| 488 |
+
if not text_columns:
|
| 489 |
+
st.error(
|
| 490 |
+
"No columns found in this CSV. At least one column is required."
|
| 491 |
+
)
|
| 492 |
+
st.stop()
|
| 493 |
+
|
| 494 |
return _list_text_columns(df_sample)
|
| 495 |
|
| 496 |
|