Screen Reloads automatically

I have developed a streamlit application to collect feedback from my users. i have given a text_input area where they can submit a feedback and press save button. on Save i am saving their feedback in a csv file. Once the feedback is saved we will now display them another case.

The case shouldn’t change till the time a person has saved his/her input.

However users are complaining

  1. Screen Automatically changes the case even without doing anything.
  2. As they are typing their feedback and haven’t pressed save and just clicked on the page somewhere the case changes.

Can you please help me solving this.


Vikkas Goel

Hello @Vikkas_Goel,

My guess is you’re encountering a workflow issue with your app. Could you provide some code to see exactly where the problem comes from? It’d be easier to help you :slight_smile:

import pandas as pd
import streamlit as st
import random
from scispacy_code import codification_func
import os

def data_reader():
return pd.read_csv(‘final_data_03June_V2.csv’)

data = data_reader()

st.subheader(‘DRG Extraction Validation Tool’)
person = st.sidebar.selectbox(‘Select Validator’,(’’,‘Dr.Ajay’, ‘Dr.Rohit’,‘Dr.Renuka’,‘Vikkas’,‘Dr.Nandini’,‘Paulami’,‘Raghu’,‘Akanksha’))

if person == “”:
st.sidebar.warning(‘Please select the Validator’)

filename = person+'.csv'
if not os.path.isfile(filename):
    #st.text('i am here')
    colmns = ['claim_id','feedback']
    data_val = pd.DataFrame(columns=colmns)

data_val = pd.read_csv(filename)

drg_select = st.sidebar.selectbox('Select DRG to Validate',['Any DRG']+data['options'].unique().tolist())

if drg_select != 'Any DRG':
    data_select = data[data['options'] == drg_select]
    data_select = data.copy()
if len(data_select['Image_name'].unique().tolist()) > 24:
    case_select = st.sidebar.selectbox('Select Case to Validate',random.sample(data_select['Image_name'].unique().tolist(),24))
    case_select = st.sidebar.selectbox('Select Case to Validate',data_select['Image_name'].unique().tolist())
diagnosis = data_select[data_select['Image_name'] == case_select]['diagnosis'].values[0].replace('[','').replace(']','').replace('\'','')
procedure = data_select[data_select['Image_name'] == case_select]['procedure'].values[0].replace('[','').replace(']','').replace('\'','')'Diagnosis : '+diagnosis)'Procedure : '+procedure)

input_codif = diagnosis + ', ' + procedure

codification_df = codification_func(input_codif)

if codification_df.shape[1] > 0:
    st.warning('Extracted DRG & Other Codes')
    st.warning('No Code Found')

user_input = st.text_input("Enter your Feedback : - ", '')

if st.button('Save'):           
    if user_input == '':
        st.error('Please Check Feedback again .. ')
        data_val = data_val.append({'claim_id':case_select,'feedback':user_input},ignore_index=True)

if st.button('Show my '+str(data_val.shape[0])+' Validations'):
        #st.sidebar.text('Report is displayed below image')
        #st.table(data_val.pivot_table(values='image_name',index = 'original_label', columns = 'Validator_label',aggfunc=len).fillna(0).astype(int))
        #st.text('*** Row Names are the Predicted Names / Column Names are the validated Names')