File size: 1,593 Bytes
0331cab
 
 
510fdbb
0331cab
 
 
 
8e72ad4
0331cab
 
 
 
510fdbb
294eaab
 
 
 
0331cab
 
 
 
 
 
 
510fdbb
 
 
 
 
 
 
0331cab
 
510fdbb
 
 
0331cab
510fdbb
0331cab
510fdbb
 
 
0331cab
510fdbb
0331cab
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import streamlit as st
import pandas as pd
from PIL import Image
import os

# Define the function signature
def display_data(data: pd.DataFrame):
    st.experimental_data_editor(data)
    #st.experimental_data_editor

# Create the Streamlit app
def main():
    st.title("Upload Files and Display Data in Function Signature")

    # Create the "uploads" directory if it does not exist
    if not os.path.exists("uploads"):
        os.makedirs("uploads")

    # Create an upload form for CSV files
    st.subheader("Upload CSV Files")
    csv_file = st.file_uploader("Choose a CSV file", type=["csv"])
    
    # Create an upload form for image files
    st.subheader("Upload Image Files")
    image_file = st.file_uploader("Choose an image file", type=["jpg", "jpeg", "png"])

    # Add OS file listing of uploaded files
    st.subheader("Uploaded Files")
    files = os.listdir("uploads")
    for file in files:
        st.markdown(f"[{file}]({os.path.join('uploads', file)})")

    # Check if files are uploaded and display data in function signature
    if csv_file is not None:
        with open(os.path.join("uploads", csv_file.name), "wb") as f:
            f.write(csv_file.getbuffer())
        data = pd.read_csv(os.path.join("uploads", csv_file.name))
        display_data(data)

    if image_file is not None:
        with open(os.path.join("uploads", image_file.name), "wb") as f:
            f.write(image_file.getbuffer())
        image = Image.open(os.path.join("uploads", image_file.name))
        st.image(image, caption="Uploaded Image")

if __name__ == "__main__":
    main()