destiratnakomala commited on
Commit
5937a13
·
verified ·
1 Parent(s): b0a6f0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -15
app.py CHANGED
@@ -17,22 +17,17 @@ def main():
17
  st.title("Machine Learning")
18
 
19
  with st.expander("1: Add Your Data Source"):
20
- if uploaded_file is None:
21
- try:
22
- data = pd.read_csv('example.csv')
23
- st.info("Loaded example.csv")
24
- except FileNotFoundError:
25
- st.error("Example CSV file not found. Please upload your own CSV file.")
26
- except pd.errors.EmptyDataError:
27
- st.error("The example CSV file is empty or contains no data.")
28
- else:
29
- try:
30
  data = pd.read_csv(uploaded_file)
31
- st.success(f"Successfully loaded {uploaded_file.name}")
32
- except pd.errors.EmptyDataError:
33
- st.error("The uploaded file is empty or contains no data.")
34
- except Exception as e:
35
- st.error(f"An error occurred while reading the file: {str(e)}")
36
 
37
  with st.expander("2: DataSet Preview"):
38
  if uploaded_file is not None:
 
17
  st.title("Machine Learning")
18
 
19
  with st.expander("1: Add Your Data Source"):
20
+ uploaded_file = st.file_uploader("Upload your CSV file", type=["csv"])
21
+
22
+ # If no file is uploaded, load example.csv
23
+ if uploaded_file is None:
24
+ try:
25
+ data = pd.read_csv('example.csv') # Load example CSV
26
+ st.info("Loaded example.csv")
27
+ except FileNotFoundError:
28
+ st.error("Example CSV file not found. Please upload your own CSV file.")
29
+ else:
30
  data = pd.read_csv(uploaded_file)
 
 
 
 
 
31
 
32
  with st.expander("2: DataSet Preview"):
33
  if uploaded_file is not None: