Mpavan45 commited on
Commit
d7e25b3
·
verified ·
1 Parent(s): 6651580

Update pages/Introduction.py

Browse files
Files changed (1) hide show
  1. pages/Introduction.py +27 -12
pages/Introduction.py CHANGED
@@ -19,17 +19,32 @@ The dataset includes hotel-related information such as price, ratings, discounts
19
 
20
  # File upload section
21
  st.markdown("## Upload Your Dataset")
22
-
23
-
24
- # Define default file path
25
- default_path = r"C:\Users\YourUsername\Downloads\agoda_data.csv"
26
-
27
- # Input field to allow manual file path entry
28
- file_path = st.text_input("Enter the file path to your dataset:", value=default_path)
29
-
30
- if os.path.exists(file_path):
31
- df = pd.read_csv(file_path)
32
- st.dataframe(df.head())
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  else:
34
- st.error(f"File not found at {file_path}. Please check the path.")
35
 
 
19
 
20
  # File upload section
21
  st.markdown("## Upload Your Dataset")
22
+ uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
23
+
24
+ # Handle file upload and dataset processing
25
+ if uploaded_file is not None:
26
+ try:
27
+ # Read the uploaded CSV file
28
+ sample_data = pd.read_csv(uploaded_file)
29
+ df = pd.DataFrame(sample_data)
30
+
31
+ # Display a preview of the dataset
32
+ st.markdown("### Dataset Preview")
33
+ st.dataframe(df.head())
34
+
35
+ # Convert the dataset to CSV for download
36
+ csv = df.to_csv(index=False).encode('utf-8')
37
+
38
+ # Add a download button for the processed dataset
39
+ st.markdown("### Download Processed Dataset")
40
+ st.download_button(
41
+ label="Download Sample Dataset",
42
+ data=csv,
43
+ file_name="hotel_data.csv",
44
+ mime="text/csv"
45
+ )
46
+ except Exception as e:
47
+ st.error(f"An error occurred while processing the file: {e}")
48
  else:
49
+ st.warning("Please upload a dataset to proceed.")
50