File size: 1,739 Bytes
22cef48
f501b20
8667f0c
22cef48
8f98da4
22cef48
dd32b08
22cef48
30ed808
22cef48
 
d60537f
22cef48
 
 
d60537f
22cef48
8667f0c
22cef48
 
 
 
 
 
 
 
 
 
 
e1adfef
22cef48
 
 
 
 
 
 
f501b20
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
import streamlit as st
from utils import analyze_csv
import pandas as pd
from huggingface_hub import login

login(st.secrets["mail"])

st.set_page_config(page_title="CSV 067 Analyst", layout="wide")

st.title("CSV 067 Analyst | CSV-Dateianalyse")
st.header("Laden Sie hier Ihre CSV-Datei hoch:")

# CSV file upload
data = st.file_uploader("CSV-Datei hochladen", type="csv")
query = st.text_area("Geben Sie Ihre Frage zu den Daten ein")

if data is not None:
    try:
        # Reading CSV with error handling
        df = pd.read_csv(data)
        st.success("✅ CSV-Datei erfolgreich geladen!")
        
        # DataFrame information
        st.subheader("Dateninformationen:")
        col1, col2 = st.columns(2)
        with col1:
            st.write(f"Anzahl der Zeilen: {len(df)}")
        with col2:
            st.write(f"Anzahl der Spalten: {len(df.columns)}")
        
        # Analysis button
        if st.button("📊 Analysieren"):
            if not query:
                st.warning("⚠️ Bitte geben Sie eine Frage für die Analyse ein.")
            else:
                with st.spinner("🔄 Analyse läuft..."):
                    try:
                        result = analyze_csv(df, query)
                        
                        # Display statistical results
                        st.subheader("Analyseergebnisse:")
                        st.write(result)
                        
                    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.")