How to store and download user Session input and output data, exported in a csv?

Suppose I have an app which takes in an user input and returns an output from a model. For each session of the user, I want to store all the questions the user asked and all the answers that were returned, in arrays which later I want to export to a DataFrame and export as csv to user.
Can anyone help me out, kindly?

Hi @ayanatherate

Thanks for your quesiton. Here’s how I would approach this:

  • Use input widgets such as st.text_input, st.selectbox, st.slider to accept user input. Such values would be assigned to variables as in var1 = st.text_input('What is your favorite color?').
  • Once the app runs a model, you can pickle the model to .pkl file.
  • Write the above user input to a text file.
  • At this point, you would have txt (user input) and pkl (model) and you can allow users to download them by using st.download_button.

Hope this helps!

Best regards,

1 Like

Thanks, I have found the solution for this one. What worked for me was using st.session_state() to initalize and store each user questions and answers and later pack the same inside a Dataframe object.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.