Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,22 @@
|
|
| 1 |
import pandas as pd
|
| 2 |
import streamlit as st
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
import streamlit as st
|
| 3 |
|
| 4 |
+
uploaded_file = st.file_uploader("Choose a file")
|
| 5 |
+
if uploaded_file is not None:
|
| 6 |
+
# To read file as bytes:
|
| 7 |
+
bytes_data = uploaded_file.getvalue()
|
| 8 |
+
st.write(bytes_data)
|
| 9 |
+
|
| 10 |
+
# To convert to a string based IO:
|
| 11 |
+
stringio = StringIO(uploaded_file.getvalue().decode("utf-8"))
|
| 12 |
+
st.write(stringio)
|
| 13 |
+
|
| 14 |
+
# To read file as string:
|
| 15 |
+
string_data = stringio.read()
|
| 16 |
+
st.write(string_data)
|
| 17 |
+
|
| 18 |
+
# Can be used wherever a "file-like" object is accepted:
|
| 19 |
+
dataframe = pd.read_csv(uploaded_file)
|
| 20 |
+
st.write(dataframe)
|
| 21 |
+
|
| 22 |
+
st.table(dataframe)
|