4

I want to read some spectral data to my streamlit application. Each row in the file is a spectrum (different intensity values). So, I used st.fileuploader

spectra = st.file_uploader("upload file", type={"csv", "txt"})
spectra = pd.DataFrame(spectra_1_file)
st.write(spectra_1)

Now, I am getting only one row of data on each column I have each spectrum as comma-separated. I need to convert the input from the user to a similar fashion of pd.csv_read. Because, when I was using it, I was able to get a proper pandas data frame. I tried different methods to read. But, never got the proper way. this was the closest I could get.

Thank you in advance.

1
  • there is a method in pandas which is read_csv to read csv data and convert it into dataframe Commented Jul 4, 2021 at 19:41

2 Answers 2

5
spectra = st.file_uploader("upload file", type={"csv", "txt"})
if spectra is not None:
    spectra_df = pd.read_csv(spectra)
st.write(spectra_df)
Sign up to request clarification or add additional context in comments.

Comments

0

By using Pandas and Streamlit, you can read and upload your CSV file into your localhost.

data = pd.read_csv("csv_practice.csv") #path folder of the data file
st.write(data) #displays the table of data

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.