[Python] Streamlit st.selectbox not displaying options from .txt file

Discussão em 'Python' iniciado por Stack, Maio 26, 2025.

  1. Stack

    Stack Membro Participativo

    I'm having an issue with Streamlit's st.selectbox not displaying the options I have stored in a .txt file. Here's how I'm trying to implement it:

    I have a .txt file that contains many lines, each line being a question like:

    What is the total number of customers?
    What is the average number of customers?

    However, when I execute my app ,nothing shows up in the dropdown.

    Output Image

    Here's the code I'm using:

    with open("C:\Users\Comp\Desktop\Stream\Suggestion.txt", "r", encoding="utf-8") as f:
    Suggestions = [line.strip() for line in f if line.strip()]

    st.title("Sales AI")

    tab1, tab2 = st.tabs(["Data", "Chat History"])

    with tab1:

    # AI section
    st.subheader("Ask Questions About Your Data")
    query = st.selectbox(
    "Enter your question:",
    options=Suggestions,
    index=None,
    placeholder="Example: What is the average value in x",
    )

    Continue reading...

Compartilhe esta Página