Spaces:
Sleeping
Sleeping
Create data_loader.py
Browse files- data_loader.py +30 -0
data_loader.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#Aqui añadiremos la conexion entre Supabase y Huggingface
|
2 |
+
|
3 |
+
import pandas as pd
|
4 |
+
from supabase import create_client, Client
|
5 |
+
|
6 |
+
#Aqui van las credenciales, conectar las credenciales de Supabase en "Secrets"
|
7 |
+
|
8 |
+
#SUPABASE_URL =
|
9 |
+
#SUPABASE_KEY =
|
10 |
+
|
11 |
+
def load_data():
|
12 |
+
"""fertility, geo data, labor, population y predictions """
|
13 |
+
try:
|
14 |
+
response = supabase.from_("LabourForecast").execute()
|
15 |
+
if response.error:
|
16 |
+
st.error(f"Error fetching data: {response.error}")
|
17 |
+
return pd.DataFrame()
|
18 |
+
else:
|
19 |
+
return pd.DataFrame(response.data)
|
20 |
+
except Exception as e:
|
21 |
+
st.error(f"An error occurred: {e}")
|
22 |
+
return pd.DataFrame()
|
23 |
+
|
24 |
+
if __name__ == "__main__":
|
25 |
+
european_data = load_data()
|
26 |
+
if not european_data.empty:
|
27 |
+
print("Successfully loaded European data:")
|
28 |
+
print(european_data.head())
|
29 |
+
else:
|
30 |
+
print("Failed to load European data.")
|