Starberry15 commited on
Commit
d155428
Β·
verified Β·
1 Parent(s): aefddc0

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. 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
- with st.spinner("Reading file..."):
167
- raw_df = read_file(uploaded_file)
 
 
 
 
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")