|
import streamlit as st |
|
import pandas as pd |
|
|
|
|
|
file_path = 'Dhaka Metro Rail Fare 2.XLSX' |
|
df = pd.read_excel(file_path) |
|
|
|
|
|
required_columns = ['Origin', 'Destination', 'Fare (ΰ§³)'] |
|
if not all(col in df.columns for col in required_columns): |
|
st.write("Please ensure the file contains 'Origin', 'Destination', and 'Fare' columns.") |
|
else: |
|
|
|
st.title("Dhaka Metro Rail Fare Checker π") |
|
st.write("Below is the fare chart for Dhaka Metro Rail πΆ:") |
|
|
|
|
|
st.sidebar.title("Instructions") |
|
st.sidebar.write(""" |
|
**Welcome to the Dhaka Metro Rail Fare Checker!** |
|
|
|
*How to use:* |
|
1. Select your **Location station** from the dropdown menu. |
|
2. Select your **destination(s)** by clicking the destination buttons. |
|
3. The fare from your location to the selected destination(s) will be displayed below. |
|
4. You can select multiple destinations to check the fares for all of them. |
|
|
|
**Note:** Please select a valid origin station first. |
|
|
|
If you face any issues or need further assistance, feel free to [Contact Support on WhatsApp](https://wa.me/+8801719296601). |
|
""") |
|
|
|
|
|
default_origin = "Select Journey from" |
|
|
|
|
|
origin = st.selectbox( |
|
"Select your Location:", |
|
[default_origin] + df['Origin'].unique().tolist(), |
|
index=0 |
|
) |
|
|
|
|
|
if 'destination_select' not in st.session_state: |
|
st.session_state.destination_select = [] |
|
|
|
|
|
if origin != default_origin: |
|
st.write(f"Select your destination(s) from {origin}:") |
|
|
|
|
|
cols = st.columns(3) |
|
|
|
|
|
dest_buttons = df['Destination'].unique() |
|
for i, dest in enumerate(dest_buttons): |
|
col_idx = i % 3 |
|
with cols[col_idx]: |
|
if st.button(f"Select {dest}", key=f"btn_{dest}"): |
|
if dest not in st.session_state.destination_select: |
|
st.session_state.destination_select.append(dest) |
|
else: |
|
st.session_state.destination_select.remove(dest) |
|
|
|
|
|
if st.button("Clear All Destinations"): |
|
st.session_state.destination_select = [] |
|
|
|
|
|
destinations = st.session_state.destination_select |
|
|
|
if origin == default_origin: |
|
st.write("Please select a valid origin station to proceed.") |
|
elif origin and destinations: |
|
|
|
fare_data = df[(df['Origin'] == origin) & (df['Destination'].isin(destinations))] |
|
|
|
|
|
|
|
if not fare_data.empty: |
|
for index, row in fare_data.iterrows(): |
|
origin_to_dest_fare = row['Fare (ΰ§³)'] |
|
destination = row['Destination'] |
|
|
|
|
|
fare_message = f""" |
|
<div style="background-color: #f0f8ff; padding: 10px; margin-bottom: 12px; border-radius: 8px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);"> |
|
<h4 style="font-family: 'Arial', sans-serif; color: #003366;"> |
|
π <strong>{origin}</strong> to <strong>{destination}</strong> Fare |
|
</h4> |
|
<p style="font-family: 'Arial', sans-serif; font-size: 18px; color: #009688;"> |
|
π΅ Fare: <strong style="font-size: 20px; color: #e91e63;">{origin_to_dest_fare}ΰ§³</strong> |
|
</p> |
|
<p style="font-family: 'Arial', sans-serif; font-size: 14px; color: #555555;"> |
|
β¨ Enjoy your journey on the Dhaka Metro! π |
|
</p> |
|
</div> |
|
""" |
|
st.markdown(fare_message, unsafe_allow_html=True) |
|
else: |
|
st.write("No fare data available for the selected origin and destinations.") |
|
else: |
|
st.write("Please select both an origin and at least one destination.") |
|
|