joshuadunlop commited on
Commit
a0777f9
·
1 Parent(s): e5251a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -194,6 +194,12 @@ for i in range(row_count):
194
  answer_placeholder = st.empty()
195
  answer_placeholder.text_area(f'Answer {i+1}', key=f'answer{i}', value=st.session_state[f'session_answer{i}'])
196
 
 
 
 
 
 
 
197
  # Create a list of lists containing all URLs, questions, and answers
198
  data = [[st.session_state.get(f'url{i}', ''), st.session_state.get(f'question{i}', ''), st.session_state.get(f'session_answer{i}', '')] for i in range(row_count)]
199
 
 
194
  answer_placeholder = st.empty()
195
  answer_placeholder.text_area(f'Answer {i+1}', key=f'answer{i}', value=st.session_state[f'session_answer{i}'])
196
 
197
+ def get_table_download_link(df, filename="data.csv", text="Download CSV file"):
198
+ csv = df.to_csv(index=False)
199
+ b64 = base64.b64encode(csv.encode()).decode() # some strings <-> bytes conversions necessary here
200
+ href = f'<a href="data:file/csv;base64,{b64}" download="{filename}">{text}</a>'
201
+ return href
202
+
203
  # Create a list of lists containing all URLs, questions, and answers
204
  data = [[st.session_state.get(f'url{i}', ''), st.session_state.get(f'question{i}', ''), st.session_state.get(f'session_answer{i}', '')] for i in range(row_count)]
205