Mpavan45 commited on
Commit
97c1648
·
verified ·
1 Parent(s): 3b5e12b

Update pages/Introduction.py

Browse files
Files changed (1) hide show
  1. pages/Introduction.py +14 -27
pages/Introduction.py CHANGED
@@ -1,5 +1,6 @@
1
  import streamlit as st
2
  import pandas as pd
 
3
 
4
  # Set up the app's title and description
5
  st.title("Hotel Data Analysis App")
@@ -18,31 +19,17 @@ The dataset includes hotel-related information such as price, ratings, discounts
18
 
19
  # File upload section
20
  st.markdown("## Upload Your Dataset")
21
- uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
22
-
23
- # Handle file upload and dataset processing
24
- if uploaded_file is not None:
25
- try:
26
- # Read the uploaded CSV file
27
- sample_data = pd.read_csv(uploaded_file)
28
- df = pd.DataFrame(sample_data)
29
-
30
- # Display a preview of the dataset
31
- st.markdown("### Dataset Preview")
32
- st.dataframe(df.head())
33
-
34
- # Convert the dataset to CSV for download
35
- csv = df.to_csv(index=False).encode('utf-8')
36
-
37
- # Add a download button for the processed dataset
38
- st.markdown("### Download Processed Dataset")
39
- st.download_button(
40
- label="Download Sample Dataset",
41
- data=csv,
42
- file_name="hotel_data.csv",
43
- mime="text/csv"
44
- )
45
- except Exception as e:
46
- st.error(f"An error occurred while processing the file: {e}")
47
  else:
48
- st.warning("Please upload a dataset to proceed.")
 
 
1
  import streamlit as st
2
  import pandas as pd
3
+ import os
4
 
5
  # Set up the app's title and description
6
  st.title("Hotel Data Analysis App")
 
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
+