Update app.py
Browse files
app.py
CHANGED
@@ -178,7 +178,7 @@ for i in range(row_count):
|
|
178 |
df_key = f"df_{i}"
|
179 |
df = st.session_state.get(df_key)
|
180 |
if df is not None:
|
181 |
-
dfs.append(df) # Append DataFrame to the list
|
182 |
csv = convert_df_to_csv(df)
|
183 |
with col2:
|
184 |
st.download_button(
|
@@ -215,6 +215,18 @@ if generate_button:
|
|
215 |
url_id, df = results.get()
|
216 |
st.session_state[f"df_{url_id}"] = df
|
217 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
# Combined CSV download logic - this should be outside of the for loop
|
219 |
if dfs:
|
220 |
combined_csv = concatenate_dfs(dfs)
|
|
|
178 |
df_key = f"df_{i}"
|
179 |
df = st.session_state.get(df_key)
|
180 |
if df is not None:
|
181 |
+
dfs.append(df) # Append DataFrame to the list
|
182 |
csv = convert_df_to_csv(df)
|
183 |
with col2:
|
184 |
st.download_button(
|
|
|
215 |
url_id, df = results.get()
|
216 |
st.session_state[f"df_{url_id}"] = df
|
217 |
|
218 |
+
# Check if there's at least one DataFrame available for combined download
|
219 |
+
if any(st.session_state.get(f"df_{i}") is not None for i in range(row_count)):
|
220 |
+
if st.sidebar.button("Download Combined CSV"):
|
221 |
+
combined_csv = concatenate_dfs([st.session_state.get(f"df_{i}") for i in range(row_count) if st.session_state.get(f"df_{i}") is not None])
|
222 |
+
st.sidebar.download_button(
|
223 |
+
label="Download Combined Data as CSV",
|
224 |
+
data=combined_csv,
|
225 |
+
file_name='combined_backlinks.csv',
|
226 |
+
mime='text/csv',
|
227 |
+
key="combined_download" # Unique key for the combined download button
|
228 |
+
)
|
229 |
+
|
230 |
# Combined CSV download logic - this should be outside of the for loop
|
231 |
if dfs:
|
232 |
combined_csv = concatenate_dfs(dfs)
|