Spaces:
Sleeping
Sleeping
File size: 1,265 Bytes
8cc5633 8b0f996 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import os
import pandas as pd
from huggingface_hub import hf_hub_download
from streamlit_simulation.config_streamlit import DATA_PATH
HF_REPO = "dlaj/energy-forecasting-files"
HF_FILENAME = "data/processed/energy_consumption_aggregated_cleaned.csv"
def load_data():
# Prüfe, ob lokale Datei existiert
if not os.path.exists(DATA_PATH):
print(f"Lokale Datei nicht gefunden: {DATA_PATH}")
print("Lade von Hugging Face...")
# Lade von HF Hub
downloaded_path = hf_hub_download(
repo_id=HF_REPO,
filename=HF_FILENAME,
repo_type="dataset",
cache_dir="hf_cache", # Optional: lokaler Cache-Ordner
)
return pd.read_csv(downloaded_path, parse_dates=["date"])
print(f"Lade lokale Datei: {DATA_PATH}")
return pd.read_csv(DATA_PATH, parse_dates=["date"])
def resolve_csv_path() -> str:
if os.path.exists(DATA_PATH):
print(f"Lokale Datei verwendet: {DATA_PATH}")
return DATA_PATH
else:
print(f"Lokale Datei nicht gefunden, lade von HF: {HF_FILENAME}")
return hf_hub_download(
repo_id=HF_REPO,
filename=HF_FILENAME,
repo_type="dataset",
cache_dir="hf_cache",
)
|