Spaces:
Sleeping
Sleeping
File size: 1,948 Bytes
22cef48 78ba477 8667f0c 22cef48 8f98da4 78ba477 d844672 dd32b08 78ba477 30ed808 78ba477 22cef48 d60537f 78ba477 d60537f 78ba477 8667f0c 78ba477 22cef48 78ba477 22cef48 78ba477 22cef48 78ba477 22cef48 e1adfef 78ba477 22cef48 78ba477 22cef48 78ba477 22cef48 78ba477 22cef48 78ba477 22cef48 8667f0c 22cef48 | 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 45 46 47 48 49 50 51 52 53 | import streamlit as st
from utils import csv_analysieren
import pandas as pd
from huggingface_hub import login
# Seitenkonfiguration
st.set_page_config(page_title="CSV Analysierer", layout="wide")
# Initialisierung des Sitzungsstatus, falls erforderlich
if 'initialisiert' not in st.session_state:
login(st.secrets["mail"])
st.session_state.initialisiert = True
st.title("CSV 067 Analysierer | CSV-Dateianalyse")
st.header("Laden Sie hier Ihre CSV-Datei hoch:")
# CSV-Datei-Upload
datei = st.file_uploader("CSV-Datei hochladen", type="csv")
frage = st.text_area("Geben Sie Ihre Frage zu den Daten ein")
if datei is not None:
try:
# CSV einlesen mit Fehlerbehandlung
df = pd.read_csv(datei)
st.success("✅ CSV-Datei erfolgreich geladen!")
# DataFrame-Informationen
st.subheader("Dateninformationen:")
spalte1, spalte2 = st.columns(2)
with spalte1:
st.write(f"Anzahl der Zeilen: {len(df)}")
with spalte2:
st.write(f"Anzahl der Spalten: {len(df.columns)}")
# Analyse-Button
if st.button("📊 Analysieren"):
if not frage:
st.warning("⚠️ Bitte geben Sie eine Frage für die Analyse ein.")
else:
with st.spinner("🔄 Analyse läuft..."):
try:
ergebnis = csv_analysieren(df, frage)
# Statistische Ergebnisse anzeigen
st.subheader("Analyseergebnisse:")
st.write(ergebnis)
except Exception as e:
st.error(f"❌ Fehler bei der Analyse: {str(e)}")
except Exception as e:
st.error(f"❌ Fehler beim Lesen der Datei: {str(e)}")
st.write("Stellen Sie sicher, dass die Datei ein gültiges CSV-Format hat.") |