Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +18 -1
src/streamlit_app.py
CHANGED
|
@@ -3,6 +3,23 @@ import pandas as pd
|
|
| 3 |
import numpy as np
|
| 4 |
import matplotlib.pyplot as plt
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# =========================
|
| 7 |
# Page Config
|
| 8 |
# =========================
|
|
@@ -92,7 +109,7 @@ st.markdown("<div class='step-box'>", unsafe_allow_html=True)
|
|
| 92 |
st.subheader("🟢 Step 1: Upload Dataset")
|
| 93 |
|
| 94 |
if uploaded_file is not None:
|
| 95 |
-
df =
|
| 96 |
st.session_state.df = df
|
| 97 |
|
| 98 |
st.success("Dataset loaded successfully!")
|
|
|
|
| 3 |
import numpy as np
|
| 4 |
import matplotlib.pyplot as plt
|
| 5 |
|
| 6 |
+
# =========================
|
| 7 |
+
# Utility: Load CSV with auto header detection
|
| 8 |
+
# =========================
|
| 9 |
+
def load_csv_auto(uploaded_file):
|
| 10 |
+
"""
|
| 11 |
+
Load CSV file and automatically handle missing headers.
|
| 12 |
+
"""
|
| 13 |
+
# First attempt: assume CSV has header
|
| 14 |
+
df = pd.read_csv(uploaded_file)
|
| 15 |
+
|
| 16 |
+
# If no numeric columns detected, retry without header
|
| 17 |
+
if df.select_dtypes(include=[np.number]).shape[1] == 0:
|
| 18 |
+
df = pd.read_csv(uploaded_file, header=None)
|
| 19 |
+
df.columns = [f"column_{i}" for i in range(df.shape[1])]
|
| 20 |
+
|
| 21 |
+
return df
|
| 22 |
+
|
| 23 |
# =========================
|
| 24 |
# Page Config
|
| 25 |
# =========================
|
|
|
|
| 109 |
st.subheader("🟢 Step 1: Upload Dataset")
|
| 110 |
|
| 111 |
if uploaded_file is not None:
|
| 112 |
+
df = load_csv_auto(uploaded_file)
|
| 113 |
st.session_state.df = df
|
| 114 |
|
| 115 |
st.success("Dataset loaded successfully!")
|