File size: 2,716 Bytes
e45918d
 
 
c922e1e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191ca91
c922e1e
 
 
 
 
 
 
 
 
 
 
 
 
 
784bfb3
 
 
 
b4dc1f8
784bfb3
c922e1e
b4dc1f8
 
 
 
 
 
 
 
a230d54
c922e1e
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import streamlit as st
import pandas as pd

# Load the Excel file into a DataFrame (adjust the file path accordingly)
df = pd.read_excel('Book1.xlsx')

# Clean up the DataFrame (strip any unnecessary whitespaces in column names)
df.columns = df.columns.str.strip()

# Function to clean routes and remove unwanted characters
def clean_route(route):
    # Remove the "_x000D_" carriage return issue and other unwanted characters
    return route.replace("_x000D_", "").strip()

# Function to search buses by location
def search_by_location(location):
    # Filter buses that have the location in their routes
    buses_with_location = df[df['Routes'].str.contains(location, case=False, na=False)]
    return buses_with_location

# Function to get the route of a selected bus
def get_route_by_bus(bus_name):
    # Get the route for the selected bus
    bus_route = df[df['Dhaka Local Buses'] == bus_name]['Routes'].values
    if len(bus_route) > 0:
        return clean_route(bus_route[0])  # Clean the route before returning
    else:
        return "No route found for this bus."

# Streamlit app
def main():
    st.title("Dhaka Local 🚌 and 🏞 Finder")
    
    # Bus Name Search Section
    st.header("Search Bus Name")
    
    # Add a placeholder as the default option for the selectbox
    bus_name = st.selectbox(
        'Select a Bus Name from dropdown', 
        ['Select Bus Name from dropdown'] + df['Dhaka Local Buses'].tolist()  # Adding the placeholder at the beginning
    )
    
    if bus_name != 'Select Bus Name from dropdown':  # Proceed only if a valid bus is selected
        route = get_route_by_bus(bus_name)
        st.write(f"Routes for **{bus_name}**:")
        st.write(route)

    # Expander for location names (moved here)
    with st.expander("Bus Names for your assistance!!!", expanded=False):
        st.write(
            "Achim Paribahan Bus Route (আছিম পরিবহন), Active Paribahan Bus Route (এক্টিভ পরিবহন), Agradut Bus Route (অগ্রদূত), Airport Bangabandhu Avenue Bus Route(এয়ারপোর্ট বঙ্গবন্ধু এভিনিউ ট্রান্সপোর্ট), Ajmeri Glory Bus Route (আজমেরী গ্লোরী), ..."
        )
    
    # Layout hack using empty and columns for bottom-right placement
    col1, col2 = st.columns([1, 6])  # The first column is narrow
    with col2:
        # Place the image in the bottom-right of the screen
        st.image("149656-200.png", width=150, height=150)
    
    # Add space at the bottom to simulate the "bottom-right" positioning
    st.markdown("<br><br><br><br>", unsafe_allow_html=True)

if __name__ == "__main__":
    main()