import streamlit as st import pandas as pd from datetime import datetime import pytz from wordcloud import WordCloud import matplotlib.pyplot as plt import plotly.express as px import plotly.io as pio # Désactiver l'utilisation de orjson pio.orjson = None # 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(): data = pd.read_json("conferences.json") 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(): st.title("👋 GITEX AFRICA FREE CONFERENCES") st.markdown("---") st.markdown("Made with ❤ by [Bibou.ai](https://www.linkedin.com/in/halimbahae/)") data = load_data() local_timezone = pytz.timezone('Africa/Casablanca') current_time_local = pd.Timestamp.now(local_timezone) current_time_utc = current_time_local.astimezone(pytz.utc) st.write(f"Current Time: {current_time_local.strftime('%d/%m/%Y %H:%M')} (Africa/Casablanca)") # Find conferences happening now # conferences_now = data[(data['StartTime'] <= current_time_utc) & (data['EndTime'] >= current_time_utc)] conferences_now = data[(data['StartTime'] >= current_time_utc) & (data['EndTime'] <= current_time_utc)] # 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'].astimezone(local_timezone).strftime("%d/%m/%Y %H:%M") # end_time = row['EndTime'].astimezone(local_timezone).strftime("%d/%m/%Y %H:%M") # st.markdown(f"{start_time} - {end_time} (Africa/Casablanca)") # 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. 🤷") # Display all conferences st.markdown("# All Conferences 👇") if not data.empty: for index, row in data.iterrows(): st.markdown(f"### {row['SessionTitle']}") start_time = row['StartTime'].astimezone(local_timezone).strftime("%d/%m/%Y %H:%M") end_time = row['EndTime'].astimezone(local_timezone).strftime("%d/%m/%Y %H:%M") st.markdown(f"{start_time} - {end_time} (Africa/Casablanca)") 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 available. 🤷") data['Date'] = data['StartTime'].dt.date # data['Date'] = data['StartTime'].dt.date selected_day = st.sidebar.selectbox("Select Day", ["Select All"] + sorted(data['Date'].unique())) selected_location = st.sidebar.selectbox("Select Location", ["Select All"] + list(data['Location'].unique())) time_period = st.sidebar.selectbox("Select Time Period", ["Select All", "Morning", "Evening"]) track_names = ["Select All"] + list(data['TrackName'].unique()) selected_track = st.sidebar.selectbox("Select Track", track_names) 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: columns_to_display = ['StartTime', 'EndTime', 'SessionTitle', 'SessionDescription', 'TrackName', 'Location', 'Speakers', 'Date'] filtered_data = filtered_data[columns_to_display] num_rows = st.sidebar.selectbox("Number of rows to display", ["All", 10, 20, 50]) filtered_data['Speakers'] = filtered_data['Speakers'].apply(lambda speakers: ', '.join([f"{speaker['SpeakerName']} - {speaker['JobTitle']}" for speaker in speakers])) filtered_data['StartTime'] = filtered_data['StartTime'].dt.strftime("%d/%m/%Y %H:%M") filtered_data['EndTime'] = filtered_data['EndTime'].dt.strftime("%d/%m/%Y %H:%M") filtered_data = filtered_data.rename(columns={'StartTime': 'Start Time (UTC)', 'EndTime': 'End Time (UTC)'}) 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 filtres. 🤷") st.markdown(""" """, unsafe_allow_html=True) st.markdown("# Track/Day") fig = px.histogram(data, x='Date', color='TrackName') fig.update_layout(barmode='group') fig.update_layout(legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1)) fig.update_layout(height=600) st.plotly_chart(fig) # Location/Day st.markdown("# Location/Day") fig_location_day = px.histogram(data, x='Date', color='Location') fig_location_day.update_layout(barmode='group') fig_location_day.update_layout(legend=dict(orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1)) fig_location_day.update_layout(height=600) st.plotly_chart(fig_location_day) if __name__ == "__main__": main()