ML_Automate_Hub / pages /1_Upload_the_data.py
Harika22's picture
Update pages/1_Upload_the_data.py
68b52e6 verified
import streamlit as st
import pandas as pd
st.markdown("""
<div style="text-align: center; margin-bottom: 20px;">
<h2 style="color: #c71585; font-size: 28px;">Upload Your Classification Dataset📂</h2>
<p style="font-size: 18px; color: #4F4F4F;">
Upload your dataset in CSV, Excel, JSON, XML, or HTML format. Drag and drop your file or click to browse.
</p>
</div>
""", unsafe_allow_html=True)
# Upload the file
uploaded_file = st.file_uploader(
"Drop your dataset here or click to upload",
type=["csv", "xlsx", "json", "xml", "html"]
)
if uploaded_file:
file_extension = uploaded_file.name.split(".")[-1]
try:
if file_extension == "csv":
df = pd.read_csv(uploaded_file)
elif file_extension == "xlsx":
df = pd.read_excel(uploaded_file)
elif file_extension == "json":
df = pd.read_json(uploaded_file)
elif file_extension == "xml":
df = pd.read_xml(uploaded_file)
elif file_extension == "html":
df = pd.read_html(uploaded_file)[0]
else:
st.error("❌ Unsupported file format!")
st.stop()
st.session_state.df = df
st.success(f"{uploaded_file.name} uploaded successfully!✅")
# if the data upload Successfully Display the Data
st.dataframe(df.head())
st.markdown("#### You're All Set! What’s Next?📌")
with st.expander("Simple EDA🔍"):
st.info("Simple EDA helps in understanding the dataset structure, ensuring data quality, and avoiding errors in modeling.")
if st.button("➡️Proceed to Simple EDA"):
st.switch_page("pages/2_Simple_EDA.py")
except Exception as e:
st.error(f"⚠️ Error loading the file: {e}")