CSVVisualizer.py aktualisiert
Open the CSV Find the first line where the first cell starts with "Cycle" Use that entire line as the plot title (Chat)
This commit is contained in:
parent
f06ccc2e6a
commit
a3bbfac3cf
@ -68,11 +68,13 @@ class CSVVisualizer:
|
|||||||
if not filepath:
|
if not filepath:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.graph_title = "Battery Test Analysis" # Default title
|
||||||
with open(filepath, 'r') as f:
|
with open(filepath, 'r') as f:
|
||||||
reader = csv.reader(f)
|
reader = csv.reader(f)
|
||||||
headers = next(reader) # Zeile 0
|
for row in reader:
|
||||||
second_line = next(reader, []) # Zeile 1 (Titel)
|
if row and row[0].startswith("Cycle"):
|
||||||
self.graph_title = second_line[0] if second_line else "Battery Test Analysis"
|
self.graph_title = ", ".join(row).strip()
|
||||||
|
break
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# First detect problematic lines
|
# First detect problematic lines
|
||||||
@ -103,7 +105,7 @@ class CSVVisualizer:
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Now read only valid lines
|
# Now read only valid lines
|
||||||
self.status_var.set("Verarbeite gültige Zeilen…")
|
self.status_var.set("Verarbeite gültige Zeile...")
|
||||||
self.root.update_idletasks()
|
self.root.update_idletasks()
|
||||||
self.df = pd.read_csv(
|
self.df = pd.read_csv(
|
||||||
filepath,
|
filepath,
|
||||||
@ -123,7 +125,7 @@ class CSVVisualizer:
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.file_label.config(text=os.path.basename(filepath))
|
self.file_label.config(text=os.path.basename(filepath))
|
||||||
self.status_var.set(f"Loaded: {len(self.df)} valid measurements")
|
self.status_var.set(f"Working with: {len(self.df)} valid measurements...")
|
||||||
self.root.update_idletasks()
|
self.root.update_idletasks()
|
||||||
self.update_plot()
|
self.update_plot()
|
||||||
|
|
||||||
@ -148,7 +150,7 @@ class CSVVisualizer:
|
|||||||
# Spannung plotten
|
# Spannung plotten
|
||||||
self.ax.plot(df_clean["Relative_Time(s)"], df_clean["Voltage(V)"],
|
self.ax.plot(df_clean["Relative_Time(s)"], df_clean["Voltage(V)"],
|
||||||
label="Voltage (V)", color="black", linewidth=1.5)
|
label="Voltage (V)", color="black", linewidth=1.5)
|
||||||
self.ax.margins(x=0)
|
#self.ax.margins(x=0)
|
||||||
|
|
||||||
# Phasen als farbige Hintergründe
|
# Phasen als farbige Hintergründe
|
||||||
start_idx = 0
|
start_idx = 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user