I want to receive different data sheets from users.First, users need to click to determine their own data table type; Then upload the file; After that, the program performs a series of operations.
But the problem I encounter is that when the user changes the options, the previously uploaded files will not disappear.When the file is manually closed and uploaded again, an error will be reported.
The following is my code. In order to facilitate understanding, I simplified some programs, but the functions are consistent
def getFile():
uploaded_file = st.file_uploader("Please")
if uploaded_file is not None:
df = pd.read_excel(uploaded_file)
AgGrid(
df.head(3),
fit_columns_on_grid_load=False,
height=120,
editable=False,
)
return df
if __name__ == '__main__':
a=input()
if a=='a':
data=getFile()
# ... ...
else:
data=getFile()
# ... ...