i am new to streamlit. I am trying to upload spss file via st.uploader but i am getting this error.
TypeError: expected str, bytes or os.PathLike object, not UploadedFile
#Folloaing is the code
file = st.file_uploader(āPlease choose a fileā)
if file is not None:
#To read file as bytes:
bytes_data = file.getvalue()
st.write(bytes_data)
#To convert to a string based IO:
stringio = StringIO(file.getvalue().decode("latin1")) #(when i tried utf-8 i got cant convert utf-8 at a axx position. so i changed it to latin1 but now i am getting above metioned error)
st.write(stringio)
#To read file as string:
string_data = stringio.read()
st.write(string_data)
#Can be used wherever a "file-like" object is accepted:
df= pd.read_spss(file)
I donāt have your data and the code in your post is not properly formatted, so I had to make up the data and guess how the code actually looks like. With those caveats, the code works for me.
i have tried multiple datasets. its not about datasets. May be there is an issue with my code. if you have uploaded .sav file. Kindly share syntax. i wanna figure out the mistake i am making in the code. thanks
I donāt have a .sav file to try so I used a .csv file instead. The code is the same except I used pd.read_csv(file) instead of pd.read_spss(file) in the last line.