Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +7 -2
src/streamlit_app.py
CHANGED
|
@@ -37,6 +37,7 @@ else:
|
|
| 37 |
|
| 38 |
# ---------- UTILITIES ----------
|
| 39 |
def read_file(uploaded_file):
|
|
|
|
| 40 |
name = uploaded_file.name.lower()
|
| 41 |
try:
|
| 42 |
if name.endswith(('.csv', '.txt')):
|
|
@@ -163,8 +164,12 @@ with st.sidebar:
|
|
| 163 |
uploaded_file = st.file_uploader("π Upload CSV or Excel file", type=['csv', 'xls', 'xlsx', 'txt'])
|
| 164 |
|
| 165 |
if uploaded_file:
|
| 166 |
-
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
|
| 169 |
if show_raw_preview:
|
| 170 |
st.subheader("Raw Data Preview")
|
|
|
|
| 37 |
|
| 38 |
# ---------- UTILITIES ----------
|
| 39 |
def read_file(uploaded_file):
|
| 40 |
+
"""Read uploaded file and return DataFrame"""
|
| 41 |
name = uploaded_file.name.lower()
|
| 42 |
try:
|
| 43 |
if name.endswith(('.csv', '.txt')):
|
|
|
|
| 164 |
uploaded_file = st.file_uploader("π Upload CSV or Excel file", type=['csv', 'xls', 'xlsx', 'txt'])
|
| 165 |
|
| 166 |
if uploaded_file:
|
| 167 |
+
# β
FIX: Save to /tmp for Hugging Face Spaces compatibility
|
| 168 |
+
temp_path = os.path.join("/tmp", uploaded_file.name)
|
| 169 |
+
with open(temp_path, "wb") as f:
|
| 170 |
+
f.write(uploaded_file.getbuffer())
|
| 171 |
+
with open(temp_path, "rb") as f:
|
| 172 |
+
raw_df = read_file(f)
|
| 173 |
|
| 174 |
if show_raw_preview:
|
| 175 |
st.subheader("Raw Data Preview")
|