shukdevdatta123 commited on
Commit
e45918d
·
verified ·
1 Parent(s): f597e0e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -0
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+
4
+ # Load the Excel file into a DataFrame (adjust the file path accordingly)
5
+ df = pd.read_excel('Book1.xlsx')
6
+
7
+ # Clean up the DataFrame (strip any unnecessary whitespaces in column names)
8
+ df.columns = df.columns.str.strip()
9
+
10
+ # Function to search buses by location
11
+ def search_by_location(location):
12
+ # Filter buses that have the location in their routes
13
+ buses_with_location = df[df['Routes'].str.contains(location, case=False, na=False)]
14
+ return buses_with_location
15
+
16
+ # Function to get the route of a selected bus
17
+ def get_route_by_bus(bus_name):
18
+ # Get the route for the selected bus
19
+ bus_route = df[df['Dhaka Local Buses'] == bus_name]['Routes'].values
20
+ if len(bus_route) > 0:
21
+ return bus_route[0]
22
+ else:
23
+ return "No route found for this bus."
24
+
25
+ # Streamlit app
26
+ def main():
27
+ st.title("Dhaka Local Buses and Routes Finder")
28
+
29
+ # Bus Name Search Section
30
+ st.header("Search Bus Name")
31
+ bus_name = st.selectbox('Select a Bus Name', df['Dhaka Local Buses'].tolist())
32
+ if bus_name:
33
+ route = get_route_by_bus(bus_name)
34
+ st.write(f"Routes for **{bus_name}**:")
35
+ st.write(route)
36
+
37
+ # Location Search Section
38
+ st.header("Search Location")
39
+ location = st.text_input('Enter a location (e.g., Gabtoli, Mirpur)', '').strip()
40
+ if location:
41
+ buses = search_by_location(location)
42
+ if not buses.empty:
43
+ st.write(f"Buses passing through **{location}**:")
44
+ for idx, row in buses.iterrows():
45
+ st.write(f"- {row['Dhaka Local Buses']}: {row['Routes']}")
46
+ else:
47
+ st.write(f"No buses found for the location '**{location}**'.")
48
+
49
+ if __name__ == "__main__":
50
+ main()