import streamlit as st import pandas as pd from datetime import datetime import pytz # Set Streamlit page title st.set_page_config(page_title="GITEX AFRICA FREE CONFERENCES", layout="wide") # Load JSON data @st.cache_data def load_data(): # LOAD JSON data: data = pd.read_json("conferences.json") # Convert StartTime and EndTime columns to Timestamp data['StartTime'] = pd.to_datetime(data['StartTime'], utc=True) data['EndTime'] = pd.to_datetime(data['EndTime'], utc=True) return data # Main function to run the app def main(): # Set page title and footer st.title("GITEX AFRICA FREE CONFERENCES") st.markdown("---") st.markdown("Made with ❤ by [Bibou.ai](https://www.linkedin.com/in/halimbahae/)") # Load data data = load_data() # Conferences happening now current_time = pd.Timestamp(datetime.now(pytz.timezone('Africa/Casablanca'))) conferences_now = data[(pd.to_datetime(data['StartTime']) <= current_time) & (pd.to_datetime(data['EndTime']) >= current_time)] # Display current time st.write(f"Current Time: {current_time}") # Display Conferences happening now st.markdown("# Happening Now") if not conferences_now.empty: for index, row in conferences_now.iterrows(): st.markdown(f"### {row['SessionTitle']}") start_time = row['StartTime'].strftime("%d/%m/%Y %H:%M") end_time = row['EndTime'].strftime("%d/%m/%Y %H:%M") st.markdown(f"{start_time} - {end_time}") st.markdown(f"#### Location: {row['Location']}") st.markdown(f"#### Speakers:") for speaker in row['Speakers']: st.image(speaker['ImageURL'], caption=f"{speaker['SpeakerName']} - {speaker['JobTitle']}", width=200, use_column_width=False) st.markdown("---") else: st.write("No conferences are happening now.") # Extract date part from StartTime column data['Date'] = data['StartTime'].dt.date # Filter by day selected_day = st.sidebar.selectbox("Select Day", ["Select All"] + sorted(data['Date'].unique())) # Filter by location selected_location = st.sidebar.selectbox("Select Location", ["Select All"] + list(data['Location'].unique())) # Filter by morning or evening time_period = st.sidebar.selectbox("Select Time Period", ["Select All", "Morning", "Evening"]) # Filter by track name track_names = ["Select All"] + list(data['TrackName'].unique()) selected_track = st.sidebar.selectbox("Select Track", track_names) # Apply filters filtered_data = data.copy() if selected_day != "Select All": filtered_data = filtered_data[filtered_data['Date'] == selected_day] if selected_location != "Select All": filtered_data = filtered_data[filtered_data['Location'] == selected_location] if time_period != "Select All": if time_period == "Morning": filtered_data = filtered_data[filtered_data['StartTime'].dt.hour < 12] elif time_period == "Evening": filtered_data = filtered_data[filtered_data['StartTime'].dt.hour >= 12] if selected_track != "Select All": filtered_data = filtered_data[filtered_data['TrackName'] == selected_track] st.markdown("# Filtered Conferences") if not filtered_data.empty: # Select only the specified columns columns_to_display = ['StartTime', 'EndTime', 'SessionTitle', 'SessionDescription', 'TrackName', 'Location', 'Speakers', 'Date'] filtered_data = filtered_data[columns_to_display] # Add a selectbox for number of rows to display, including "All" num_rows = st.sidebar.selectbox("Number of rows to display", ["All", 10, 20, 50]) # Format speakers information filtered_data['Speakers'] = filtered_data['Speakers'].apply(lambda speakers: ', '.join([f"{speaker['SpeakerName']} - {speaker['JobTitle']}" for speaker in speakers])) # Display the table based on the selected number of rows if num_rows == "All": st.dataframe(filtered_data, height=600) else: st.dataframe(filtered_data.head(int(num_rows)), height=600) else: st.write("No sessions found for the selected filters.") # Add CSS to make the table wider st.markdown(""" """, unsafe_allow_html=True) # Run the app if __name__ == "__main__": main()