Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,25 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
# Set the title of the app
|
| 4 |
-
st.title("Basic Streamlit App with Form")
|
| 5 |
|
| 6 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
with st.form("user_form"):
|
| 8 |
# Display a header
|
| 9 |
st.header("Welcome to Streamlit Form!")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
|
| 4 |
# Set the title of the app
|
| 5 |
+
st.title("Basic Streamlit App with Form and File Upload")
|
| 6 |
|
| 7 |
+
# Sidebar for file upload
|
| 8 |
+
st.sidebar.header("Upload CSV File")
|
| 9 |
+
uploaded_file = st.sidebar.file_uploader("Choose a CSV file", type="csv")
|
| 10 |
+
|
| 11 |
+
# Display the uploaded file's content if a file is uploaded
|
| 12 |
+
if uploaded_file:
|
| 13 |
+
# Read the CSV file
|
| 14 |
+
try:
|
| 15 |
+
data = pd.read_csv(uploaded_file)
|
| 16 |
+
st.sidebar.success("File uploaded successfully!")
|
| 17 |
+
st.sidebar.write("Preview of the uploaded file:")
|
| 18 |
+
st.sidebar.dataframe(data.head()) # Display the first few rows of the data
|
| 19 |
+
except Exception as e:
|
| 20 |
+
st.sidebar.error(f"Error reading file: {e}")
|
| 21 |
+
|
| 22 |
+
# Main app - Create a form
|
| 23 |
with st.form("user_form"):
|
| 24 |
# Display a header
|
| 25 |
st.header("Welcome to Streamlit Form!")
|