From 7cef5f890064d29b5b5427a51494651007e3df37 Mon Sep 17 00:00:00 2001 From: shuaibird Date: Sun, 8 Sep 2024 12:26:23 +0800 Subject: [PATCH] Fix: Skip empty lines and filter empty strings when processing matrix rows - Added a check to skip empty lines in the input file. - Applied a filter to remove strings containing only spaces from the split result. --- AugmentedMatrixToRREF.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AugmentedMatrixToRREF.py b/AugmentedMatrixToRREF.py index 3239c5d..59c2a32 100644 --- a/AugmentedMatrixToRREF.py +++ b/AugmentedMatrixToRREF.py @@ -21,7 +21,9 @@ def is_number(s): print("Hello, getting matrix data...") with open("matrix.txt", "r") as f: for line in f: - row_string = line.rstrip('\n').split(' ') + if (not line.strip()): + continue + row_string = list(filter(lambda x: x.strip(), line.rstrip('\n').split(' '))) row = [] for i in row_string: try: