Fix method reading from and adding examples to file

This commit is contained in:
Michał Czekański 2020-05-24 17:12:35 +02:00
parent 8e9d0c1267
commit ed58517b82

View File

@ -117,7 +117,7 @@ class ExamplesManager:
dstFromRest) dstFromRest)
examples.append(example) examples.append(example)
line = file.readline()
file.close() file.close()
return examples return examples
@ -132,11 +132,12 @@ class ExamplesManager:
example: SurvivalDTExample example: SurvivalDTExample
for example in examplesToAdd: for example in examplesToAdd:
strToWrite = "{}|{}|{}|{}|{}|{}|{}".format(example.classification.name, strToWrite = "\n{}|{}|{}|{}|{}|{}|{}".format(example.classification.name,
example.hungerVal.name, example.hungerVal.name,
example.thirstVal.name, example.thirstVal.name,
example.staminaVal.name, example.staminaVal.name,
example.distFromFood.name, example.distFromFood.name,
example.distFromWater.name, example.distFromWater.name,
example.distFromRestPlace.name) example.distFromRestPlace.name)
file.write(strToWrite)
file.close() file.close()