diff --git a/src/endpoints/bettwaage.py b/src/endpoints/bettwaage.py index 6c2abf5..a3ee5c3 100644 --- a/src/endpoints/bettwaage.py +++ b/src/endpoints/bettwaage.py @@ -9,6 +9,7 @@ import csv router = APIRouter() file_path = "bettwaage.csv" +header = "timestamp;tl;tr;bl;br;total;" latest_values = [] zero_values = [0, 0, 0, 0] @@ -16,7 +17,7 @@ scale_values = [1, 1, 1, 1] def add_line_to_history(line: str) -> None: - with open(file_path, "a", encoding="UTF-8") as fp: + with open(file_path, "a") as fp: fp.write(line + "\n") @@ -90,7 +91,7 @@ async def get_latest(): @router.delete("/delete", tags=["file"]) async def delete_file(): os.remove(file_path) - add_line_to_history("timestamp;tl;tr;bl;br;total;") + add_line_to_history(header) return "Deleted file and created new file with headers" @@ -113,4 +114,4 @@ async def set_scales(tl: float, tr: float, bl: float, br: float): if not os.path.exists(file_path): - add_line_to_history("timestamp;tl;tr;bl;br;total;") + add_line_to_history(header)