|
import streamlit as st |
|
import pandas as pd |
|
|
|
|
|
data = pd.read_csv("integrated_travel_data.csv") |
|
|
|
|
|
state_abbreviation_mapping = { |
|
"up": "Uttar Pradesh", |
|
"mh": "Maharashtra", |
|
"rj": "Rajasthan", |
|
"ar": "Arunachal Pradesh", |
|
"as": "Assam", |
|
"ap": "Andhra Pradesh", |
|
"andhra": "Andhra Pradesh", |
|
"wb": "West Bengal", |
|
"bengal": "West Bengal", |
|
"tn": "Tamil Nadu", |
|
"hp": "Himachal Pradesh", |
|
|
|
} |
|
|
|
def get_city_info(city): |
|
city_data = data[data['Destination'].str.lower().str.strip() == city.lower().strip()] |
|
|
|
if city_data.empty: |
|
return "City not found in the database." |
|
|
|
city_info = city_data.iloc[0] |
|
|
|
info = f"**Destination:** {city_info['Destination']}\n\n" |
|
info += f"**State:** {city_info['State']}\n\n" |
|
info += f"**Description:** {city_info['Description']}\n\n" |
|
info += "**Tourist Attractions:**\n" |
|
attractions = city_info['Tourist Attractions'].split(', ') |
|
for attraction in attractions: |
|
info += f"- {attraction}\n" |
|
info += "\n**Activities:**\n" |
|
activities = city_info['Activities'].split('. ') |
|
for activity in activities: |
|
info += f"- {activity}\n" |
|
|
|
return info |
|
|
|
def list_places_by_state(state): |
|
|
|
state_normalized = state.strip().lower() |
|
state_full_name = state_abbreviation_mapping.get(state_normalized, state_normalized) |
|
|
|
|
|
state_data = data[data['State'].str.lower().str.strip() == state_full_name.lower()] |
|
|
|
if state_data.empty: |
|
return f"No destinations found for {state_full_name}." |
|
|
|
places = state_data['Destination'].tolist() |
|
return f"**Destinations in {state_full_name}:**\n" + "\n".join([f"- {place}" for place in places]) |
|
|
|
|
|
st.set_page_config(page_title="Indian Travel Information", layout="wide") |
|
|
|
|
|
st.markdown("<h1 style='color: lightgreen;'>Indian Travel Information</h1>", unsafe_allow_html=True) |
|
st.markdown("<p style='color: white;'>Enter a state to see available destinations, then enter a city name for detailed information.</p>", unsafe_allow_html=True) |
|
st.markdown("------------------------------------------------------------------") |
|
|
|
|
|
st.sidebar.header("Search") |
|
state = st.sidebar.text_input("Enter state name or abbreviation", "") |
|
city = st.sidebar.text_input("Enter city name", "") |
|
|
|
if state: |
|
state_output = list_places_by_state(state) |
|
st.sidebar.markdown(state_output) |
|
|
|
if city: |
|
if state and city not in state_output: |
|
st.error(f"City '{city}' not found in '{state}'. Please check the city or state.") |
|
else: |
|
city_info = get_city_info(city) |
|
st.markdown(city_info) |
|
|
|
|
|
st.sidebar.header("Examples") |
|
if st.sidebar.button("Show Examples"): |
|
st.sidebar.markdown(""" |
|
**States:** |
|
- Uttar Pradesh (UP) |
|
- Maharashtra (MH) |
|
- Rajasthan (RJ) |
|
- Arunachal Pradesh (AR) |
|
- Assam (AS) |
|
- Andhra Pradesh (AP/Andhra) |
|
- West Bengal (WB/Bengal) |
|
- Tamil Nadu (TN) |
|
- Himachal Pradesh (HP) |
|
|
|
**Cities:** |
|
- Agra |
|
- Mumbai |
|
- Jaipur |
|
- Tawang |
|
- Guwahati |
|
""") |
|
|
|
|
|
st.sidebar.markdown("---") |
|
st.sidebar.title("Disclaimer") |
|
st.sidebar.write("Type either state or city once and don't type both of them at once.\n\n If you want to type at once make sure that state and city belongs to each other.") |