File size: 932 Bytes
182219d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import pandas as pd
import os
import shutil

def replace_default_dataset():
    # Replace dataset.csv with dataset_backup.csv
    dataset_backup_path = "Student_copy.csv"
    dataset_path = "Student.csv"

    if os.path.exists(dataset_backup_path):
        shutil.copy(dataset_backup_path, dataset_path)
        st.success("Default dataset applied successfully.")
    else:
        st.warning("Default dataset backup not found.")

def save_uploaded_dataset(uploaded_file):
    # Save the uploaded dataset file and replace dataset.csv
    dataset_path = "Student.csv"
    uploaded_file.seek(0)

    try:
        df = pd.read_csv(uploaded_file)
        df.to_csv(dataset_path, index=False)
        st.success("Dataset uploaded and applied successfully.")
    except pd.errors.EmptyDataError:
        st.warning("Uploaded dataset is empty.")
    except Exception as e:
        st.error(f"An error occurred: {e}")