Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +13 -16
src/streamlit_app.py
CHANGED
|
@@ -282,10 +282,6 @@ if uploaded is not None:
|
|
| 282 |
else:
|
| 283 |
df_input = pd.read_excel(uploaded)
|
| 284 |
|
| 285 |
-
st.subheader("Uploaded Data Preview")
|
| 286 |
-
st.dataframe(df_input.head(20), use_container_width=True)
|
| 287 |
-
st.info(f"{len(df_input)} rows loaded")
|
| 288 |
-
|
| 289 |
# --- Column mapping ---
|
| 290 |
st.subheader("Map Columns")
|
| 291 |
all_cols = ["(auto-detect)"] + list(df_input.columns)
|
|
@@ -311,20 +307,14 @@ if uploaded is not None:
|
|
| 311 |
rename_map[zip_col] = "Zip"
|
| 312 |
df_input = df_input.rename(columns=rename_map)
|
| 313 |
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
row_start = st.number_input("Start row", min_value=0, value=0)
|
| 318 |
-
with r2:
|
| 319 |
-
row_end = st.number_input("End row (0 = all)", min_value=0, value=0)
|
| 320 |
|
| 321 |
# --- Run button ---
|
| 322 |
if st.button("Run Scraper", type="primary", use_container_width=True):
|
| 323 |
|
| 324 |
-
|
| 325 |
-
df_work = df_input.iloc[row_start:row_end].copy()
|
| 326 |
-
else:
|
| 327 |
-
df_work = df_input.iloc[row_start:].copy()
|
| 328 |
|
| 329 |
df_work['query'] = df_work.iloc[:, :4].astype(str).apply(' '.join, axis=1)
|
| 330 |
df_work['query'] = df_work['query'] + ' square footage'
|
|
@@ -455,8 +445,15 @@ if uploaded is not None:
|
|
| 455 |
unsafe_allow_html=True,
|
| 456 |
)
|
| 457 |
|
| 458 |
-
# --- Download button ---
|
| 459 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 460 |
st.download_button(
|
| 461 |
label="Download Results CSV",
|
| 462 |
data=csv_bytes,
|
|
|
|
| 282 |
else:
|
| 283 |
df_input = pd.read_excel(uploaded)
|
| 284 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
# --- Column mapping ---
|
| 286 |
st.subheader("Map Columns")
|
| 287 |
all_cols = ["(auto-detect)"] + list(df_input.columns)
|
|
|
|
| 307 |
rename_map[zip_col] = "Zip"
|
| 308 |
df_input = df_input.rename(columns=rename_map)
|
| 309 |
|
| 310 |
+
st.subheader("Uploaded Data Preview")
|
| 311 |
+
st.dataframe(df_input.head(20), use_container_width=True)
|
| 312 |
+
st.info(f"{len(df_input)} rows loaded")
|
|
|
|
|
|
|
|
|
|
| 313 |
|
| 314 |
# --- Run button ---
|
| 315 |
if st.button("Run Scraper", type="primary", use_container_width=True):
|
| 316 |
|
| 317 |
+
df_work = df_input.copy()
|
|
|
|
|
|
|
|
|
|
| 318 |
|
| 319 |
df_work['query'] = df_work.iloc[:, :4].astype(str).apply(' '.join, axis=1)
|
| 320 |
df_work['query'] = df_work['query'] + ' square footage'
|
|
|
|
| 445 |
unsafe_allow_html=True,
|
| 446 |
)
|
| 447 |
|
| 448 |
+
# --- Download button (include mapped input columns) ---
|
| 449 |
+
input_cols = list(df_input.columns[:4])
|
| 450 |
+
df_download = df_clean.reset_index(drop=True)
|
| 451 |
+
df_work_reset = df_work[input_cols].reset_index(drop=True)
|
| 452 |
+
for col in input_cols:
|
| 453 |
+
if col not in df_download.columns and col in df_work_reset.columns:
|
| 454 |
+
df_download[col] = df_work_reset[col]
|
| 455 |
+
|
| 456 |
+
csv_bytes = df_download.to_csv(index=False, encoding='utf-8-sig').encode('utf-8-sig')
|
| 457 |
st.download_button(
|
| 458 |
label="Download Results CSV",
|
| 459 |
data=csv_bytes,
|