Spaces:
Sleeping
Sleeping
| import os | |
| import streamlit as st | |
| def upload_csv(): | |
| uploaded_file = st.file_uploader("Choose a CSV file", type="csv") | |
| if uploaded_file is not None: | |
| # Save to /tmp for Hugging Face Spaces compatibility | |
| save_path = os.path.join("/tmp", uploaded_file.name) | |
| with open(save_path, "wb") as f: | |
| f.write(uploaded_file.getbuffer()) | |
| st.success(f"File saved to {save_path}") | |
| def list_files(): | |
| # List files in /tmp directory | |
| files = [f for f in os.listdir("/tmp") if f.endswith(".csv")] | |
| if files: | |
| st.write("Uploaded CSV files:") | |
| for file in files: | |
| st.write(file) | |
| else: | |
| st.write("No CSV files found in /tmp.") |