From 9a9d40db826c10b60cbd86294563923cceae67a5 Mon Sep 17 00:00:00 2001 From: Maximilian Giller Date: Mon, 6 May 2024 22:22:13 +0200 Subject: [PATCH] Fixed file create logic --- src/endpoints/handlers/bett.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/endpoints/handlers/bett.py b/src/endpoints/handlers/bett.py index a4f27d1..91f174d 100644 --- a/src/endpoints/handlers/bett.py +++ b/src/endpoints/handlers/bett.py @@ -8,7 +8,7 @@ import requests as r from ..hue import hue file_path: str = "bettwaage.csv" -header: str = "timestamp;tl;tr;bl;br;total;" +header: str = "timestamp;tl;tr;bl;br;total;\n" bett_ip: str = "http://192.168.178.110:80" matrix_clock_api: str = "http://192.168.178.84:8000" @@ -113,9 +113,10 @@ def check_for_change(): def add_line_to_bed_history(line: str) -> None: - if not os.path.exists(file_path): - add_line_to_bed_history(header) + exists = os.path.exists(file_path) with open(file_path, "a") as fp: + if not exists: + fp.write(header) fp.write(line + "\n")