Spaces:
Running
Running
LaurentTRIPIED
commited on
Commit
•
ff94d3c
1
Parent(s):
f919c5e
Pytorch v.44
Browse files- __pycache__/organisations_engagees.cpython-312.pyc +0 -0
- app.py +16 -19
- organisations_engagees.py +13 -3
__pycache__/organisations_engagees.cpython-312.pyc
CHANGED
Binary files a/__pycache__/organisations_engagees.cpython-312.pyc and b/__pycache__/organisations_engagees.cpython-312.pyc differ
|
|
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import requests
|
2 |
import streamlit as st
|
3 |
from organisations_engagees import display_organisations_engagees
|
@@ -8,32 +9,28 @@ def get_data():
|
|
8 |
try:
|
9 |
response = requests.get(url)
|
10 |
if response.status_code == 200:
|
11 |
-
data = response.json()
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
lat, lon = geoloc
|
19 |
-
cleaned_data.append({"lat": lat, "lon": lon, "name": fields.get("nom_courant_denomination", "Inconnu")})
|
20 |
return cleaned_data
|
21 |
-
else:
|
22 |
-
st.error(f"Failed to fetch data. Status code: {response.status_code}")
|
23 |
-
return []
|
24 |
except requests.RequestException as e:
|
25 |
-
|
26 |
return []
|
27 |
|
28 |
def main():
|
29 |
-
st.
|
30 |
-
|
31 |
-
|
32 |
data = get_data()
|
33 |
-
|
|
|
34 |
display_organisations_engagees(data)
|
35 |
-
elif app_mode == "Localisation des Entreprises":
|
36 |
display_map(data)
|
37 |
-
|
|
|
|
|
38 |
if __name__ == "__main__":
|
39 |
main()
|
|
|
1 |
+
|
2 |
import requests
|
3 |
import streamlit as st
|
4 |
from organisations_engagees import display_organisations_engagees
|
|
|
9 |
try:
|
10 |
response = requests.get(url)
|
11 |
if response.status_code == 200:
|
12 |
+
data = response.json().get('records', [])
|
13 |
+
cleaned_data = [{'nom': record['fields'].get('nom'),
|
14 |
+
'adresse': record['fields'].get('adresse'),
|
15 |
+
'engagement_rse': record['fields'].get('rse', 'Non'),
|
16 |
+
'lat': record['fields'].get('geo_point_2d', [None])[0],
|
17 |
+
'lon': record['fields'].get('geo_point_2d', [None])[1]}
|
18 |
+
for record in data]
|
|
|
|
|
19 |
return cleaned_data
|
|
|
|
|
|
|
20 |
except requests.RequestException as e:
|
21 |
+
print(f"Erreur lors de la récupération des données : {e}")
|
22 |
return []
|
23 |
|
24 |
def main():
|
25 |
+
st.title("Application RSE Bordeaux Métropole")
|
26 |
+
|
|
|
27 |
data = get_data()
|
28 |
+
|
29 |
+
if data:
|
30 |
display_organisations_engagees(data)
|
|
|
31 |
display_map(data)
|
32 |
+
else:
|
33 |
+
st.write("Aucune donnée disponible pour le moment.")
|
34 |
+
|
35 |
if __name__ == "__main__":
|
36 |
main()
|
organisations_engagees.py
CHANGED
@@ -1,6 +1,6 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
-
import requests
|
4 |
|
5 |
def display_organisations_engagees(data):
|
6 |
st.markdown("## OPEN DATA RSE")
|
@@ -8,7 +8,17 @@ def display_organisations_engagees(data):
|
|
8 |
|
9 |
if not data:
|
10 |
st.write("No data available.")
|
11 |
-
|
|
|
|
|
|
|
12 |
|
13 |
if __name__ == "__main__":
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
import streamlit as st
|
3 |
import pandas as pd
|
|
|
4 |
|
5 |
def display_organisations_engagees(data):
|
6 |
st.markdown("## OPEN DATA RSE")
|
|
|
8 |
|
9 |
if not data:
|
10 |
st.write("No data available.")
|
11 |
+
else:
|
12 |
+
# Supposons que les données sont une liste de dictionnaires, où chaque dictionnaire contient des informations sur une organisation
|
13 |
+
df = pd.DataFrame(data)
|
14 |
+
st.dataframe(df)
|
15 |
|
16 |
if __name__ == "__main__":
|
17 |
+
# Pour tester, nous passerons un ensemble de données fictives, car nous ne pouvons pas exécuter Streamlit ici
|
18 |
+
# Voici un exemple de structure de données attendue
|
19 |
+
test_data = [
|
20 |
+
{'nom': 'Entreprise A', 'adresse': 'Adresse A', 'engagement_rse': 'Oui'},
|
21 |
+
{'nom': 'Entreprise B', 'adresse': 'Adresse B', 'engagement_rse': 'Non'},
|
22 |
+
# Ajouter plus de données fictives si nécessaire
|
23 |
+
]
|
24 |
+
display_organisations_engagees(test_data)
|