Multiple Selectboxes Updating Issue: After changing the input, the data only updates, if the selectbox is clicked twice

Hey guys,

I’ve come across a small issue regarding the selectbox widget.
I am using multiple selectboxes, which have the weird behaviour of only updating an input change after being clicked twice.

I’ve found the following Error in the logs, after changing the Value of the first Select-Box once:

“raise ValueError(”{} is not in iterable".format(str(x)))
ValueError: UploadedFile(id=13, name=‘_2019_AH950_Analyse.xlsm’, type=‘application/vnd.ms-excel.sheet.macroEnabled.12’, size=2077100) is not in iterable"

The Uploaded-Files are Excel-Files, which follow the naming system of: “[year][product]_Analyse.xlsm”

Here is the involved code section:

#Datei-Uploader einfügen
with st.expander("Upload"):
    iFiles = st.file_uploader("", accept_multiple_files=True, type=["xlsm"])

iFiles.sort(key=lambda x: x.name.split("_")[2])

iNames=[]
for i in iFiles:
    iNames.append(i.name.split("_")[0]+i.name.split("_")[2])

iNames=list(dict.fromkeys(iNames))

iFile=st.selectbox("Analyse-File Auswahl",iNames)

files=[]
for i in iFiles:
    if i.name.split("_")[0]+i.name.split("_")[2]==iFile:
        files.append(i)

files.sort(key=lambda x: x.name.split("_")[1])

if files != None:
    
    try:
        #Selectbox einfügen
        file=st.selectbox("Analyse-Jahr Auswahl", files, format_func=lambda x: "von "+x.name.split("_")[1])

        df = pd.read_excel(file,
                        engine="openpyxl",
                        sheet_name="Eingabe",
                        na_filter=True,
                        usecols="A")
                    
        var=[]
        var=df["Materialnummer"].values.tolist()
        var.sort()

        varA=st.selectbox("Varianten Auswahl", var)

        dfA = pd.read_excel(file,
                        engine="openpyxl",
                        sheet_name=varA + ".xlsx",
                        na_filter=True)
       
        dfK = pd.read_excel(file,
                        engine="openpyxl",
                        sheet_name="Komponenten",
                        na_filter=True)

I’d really appreciate every type of useful help.
Thank you!

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