CSVVisualizer.py aktualisiert

Überschrift angepasst
(Chat)
This commit is contained in:
Jan 2025-05-26 20:57:40 +02:00
parent 452ec10f85
commit e034150dc1

View File

@ -67,9 +67,16 @@ class CSVVisualizer:
if not filepath:
return
with open(filepath, 'r') as f:
reader = csv.reader(f)
headers = next(reader) # Zeile 0
second_line = next(reader, []) # Zeile 1 (Titel)
self.graph_title = second_line[0] if second_line else "Battery Test Analysis"
try:
# First detect problematic lines
self.status_var.set("Datei geladen prüfe Zeilen…")
good_lines = []
with open(filepath, 'r') as f:
reader = csv.reader(f)
@ -94,6 +101,7 @@ class CSVVisualizer:
return
# Now read only valid lines
self.status_var.set("Verarbeite gültige Zeilen…")
self.df = pd.read_csv(
filepath,
skiprows=lambda x: x not in good_lines and x != 0, # keep header
@ -161,7 +169,7 @@ class CSVVisualizer:
self.ax.legend(handles=patches, loc="upper right")
self.ax.set_xlabel("Time (s) since start")
self.ax.set_ylabel("Voltage (V)")
self.ax.set_title("Battery Test Analysis")
self.ax.set_title(getattr(self, 'graph_title'))
self.ax.grid(True)
# Aktualisiere den Canvas