From 3f3324d61a5d797cc205e429a3735be3a0afe387 Mon Sep 17 00:00:00 2001
From: Tammo Jan Dijkema <T.J.Dijkema@gmail.com>
Date: Thu, 15 Feb 2024 18:41:05 +0100
Subject: [PATCH] Be fault tolerant

---
 power_plot.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/power_plot.py b/power_plot.py
index 02aa31d..b87aba1 100755
--- a/power_plot.py
+++ b/power_plot.py
@@ -109,7 +109,11 @@ class PowerPlotMainWindow(QMainWindow):
         # Get metadata and ignore it
         header_lines = []
         while True:
+            # TODO: this is blocking and freezes the UI, could
+            # be refactored to use the QT notification mechanism
             line = sys.stdin.readline()
+            if len(line.strip()) == 0:
+                continue
             header_lines.append(line)
             if line[0] != "#":
                 column_names = [name.strip() for name in line.split()]
@@ -163,6 +167,10 @@ class PowerPlotMainWindow(QMainWindow):
                 continue
             self.output_counter += 1
             values = line.split(",")
+            if not values[0][0].isnumeric():
+                print("Skipping line: " + line.strip())
+                print(values[0], values[0].isnumeric())
+                continue
             time_now = float(values[0])
             power_now = float(values[self.col_num])
 
-- 
GitLab