From f025df0381db32002d7735ccbc24a669cecd6fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Czeka=C5=84ski?= Date: Sun, 24 May 2020 18:48:30 +0200 Subject: [PATCH] Fix method writing dt examples to file Method wasn't removing trailing new line chars. --- src/AI/DecisionTrees/ExamplesManager.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/AI/DecisionTrees/ExamplesManager.py b/src/AI/DecisionTrees/ExamplesManager.py index 21e081a..cb5c463 100644 --- a/src/AI/DecisionTrees/ExamplesManager.py +++ b/src/AI/DecisionTrees/ExamplesManager.py @@ -23,10 +23,12 @@ class ExamplesManager: lineNum = 0 while True: - line = file.readline() + line: str = file.readline() if line == "": break lineNum += 1 + + line = line.rstrip('\n') words = line.split("|") if len(words) != 7: @@ -133,7 +135,7 @@ class ExamplesManager: example: SurvivalDTExample for example in examplesToAdd: - strToWrite = "\n{}|{}|{}|{}|{}|{}|{}".format(example.classification.name, + strToWrite = "{}|{}|{}|{}|{}|{}|{}\n".format(example.classification.name, example.hungerVal.name, example.thirstVal.name, example.staminaVal.name,