Update pages/Introduction.py
Browse files- 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 |
-
#
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
#
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
else:
|
| 34 |
-
st.
|
| 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 |
|