NathanPap commited on
Commit
20a3dbe
·
verified ·
1 Parent(s): cf23d48

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +8 -10
utils.py CHANGED
@@ -38,17 +38,15 @@ class CSVAnalyzer:
38
  try:
39
  context = "E-Mail-Informationen:\n\n"
40
 
41
- # Ensure all values are strings and handle empty values
42
- df = df.astype(str).replace('nan', 'Keine Angabe')
43
 
44
- for idx, row in df.iterrows():
45
- context += f"E-Mail {idx + 1}:\n"
46
- context += f"Datum: {row['Datum']}\n"
47
- context += f"Absender: {row['Absender']}\n"
48
- context += f"Betreff: {row['Betreff']}\n"
49
- context += f"Inhalt: {row['Inhalt']}\n"
50
- if 'Gebäude' in row:
51
- context += f"Gebäude: {row['Gebäude']}\n"
52
  context += "---\n"
53
 
54
  return context.strip()
 
38
  try:
39
  context = "E-Mail-Informationen:\n\n"
40
 
41
+ # Convert DataFrame to string and handle missing values
42
+ df_str = df.fillna("Keine Angabe").astype(str)
43
 
44
+ # Process each row
45
+ for index in range(len(df_str)):
46
+ row = df_str.iloc[index]
47
+ context += f"E-Mail {index + 1}:\n"
48
+ for column in df_str.columns:
49
+ context += f"{column}: {row[column]}\n"
 
 
50
  context += "---\n"
51
 
52
  return context.strip()