Saving data from users into a CSV file

Hi, I want a web app which saves data from the user input and adds it into a CSV. The structure would be like this:

import csv
foo = "An"
bar = None
baz = "Example"

fields = [foo, bar, baz]
with open('Database.csv','a', newline='') as f:
    writer = csv.writer(f)

How can I deploy this?

1 Like

Hi @polgr98,

Yes, you can easily spin up a Streamlit web app to do that.

I would recommend to take a look at the Streamlit API Docs which does a great job of showing what you can do with the various Streamlit functions with example codes.

From what you described, you want to accept user input and write those to a CSV file.

Building the Streamlit app

Here’s what you can do to build the Streamlit app using 2 Streamlit functions (st.text_input and st.download_button):

Deploying the Streamlit app

You can easily deploy a Streamlit app using Streamlit Cloud which has a free and team tier.

More info on how to deploy a Streamlit app direct from the Streamlit Docs

Further learning

You can find some Streamlit tutorials on YouTube that you could follow, here are some:

Hope this helps! :grin:

1 Like