File size: 700 Bytes
cb74654
ce5f6a5
cb74654
 
ce5f6a5
cb74654
ce5f6a5
 
 
cb74654
ce5f6a5
 
cb74654
ce5f6a5
 
cb74654
ce5f6a5
cb74654
ce5f6a5
cb74654
ce5f6a5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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.")