Skip to main content

Weight / Pressure Log

·3 mins

Weight #

WeightDateTime
195.22024-09-1215:40
199.42024-08-0106:14
198.62024-07-3106:29
198.82024-07-3006:49
197.62024-07-2907:01
176.82024-07-2807:58
196.02024-07-2712:08
198.62024-07-2613:05
200.02024-07-1808:15
198.02024-07-1607:34
201.42024-07-1607:32
1972024-07-1115:02
1962024-07-0904:35
196.02024-07-0807:38
196.62024-07-0707:38
197.62024-07-0509:14
1932024-06-2807:06
194.62024-06-2708:21
199.82024-01-0706:33
200.02024-01-0608:02
197.22024-01-0505:38
201.22024-01-0307:57
199.22024-01-0106:42
198.22023-12-3106:54
195.02023-12-3008:03
196.02023-12-2904:39
196.82023-12-2808:52
197.62023-12-2706:08
196.42023-12-2607:42
193.62023-12-2505:32
192.42023-12-2405:08
194.02023-12-2204:33
192.42023-12-2103:58
194.22023-12-2010:20
193.42023-12-1904:07
191.02023-12-1406:50
191.42023-12-1404:44

BP #

SystolicDiastolicBPDateTime
11867852024-09-1215:39
12676522024-08-0106:11
10767732024-07-3106:15
13172562024-07-3006:49
11673602024-07-2907:20
12776582024-07-2807:58
12875692024-07-2712:07
12474702024-07-2613:05
12573632024-07-1808:14
11675532024-07-1607:33
14278552024-07-1607:32
11362642024-07-1115:02
10967582024-07-0904:35
10259562024-07-0807:37
10966662024-07-0707:38
10363602024-07-0509:14
11066582024-06-2807:05
11972682024-06-2708:23
12574532024-01-0609:09
10765782024-01-0507:58
11973552024-01-0307:59
12274562024-01-0106:42
12979532023-12-3106:55
11272642023-12-3008:08
11062602023-12-2808:57
10967572023-12-2707:27
10770562023-12-2607:39
10257552023-12-2507:57
11067592023-12-2209:59
11669592023-12-2105:26
10663552023-12-2011:08
11065522023-12-1807:02
10874612023-12-1805:38
12377552023-12-1405:32

The Code #

On this project I attemp to use the Unix Philosophy and also only the Python Standard Library. So at time of writing there are two separate modules for capturing weight (weight.py), and blood pressure / heart rate readings (bp.py). Those record the data in simple .csv files. A separate script (make_table.py) generates markdown tables for each of the .csv files. Last, a script to copy the markdown tables to the appropriate Hugo directory where they are included in creation of the final page. link here.

#!/usr/bin/python3

import sys
import subprocess
from datetime import datetime

"""
get weight as command line argument.  Format as Weight, Date, Time and 
store in csv file.  Note no header in csv file.
"""


def get_weight(weight):

    date = datetime.now().strftime("%Y-%m-%d")

    time = datetime.now().strftime("%H:%M")

    weight = f"{weight}, {date}, {time} \n"
    print ("Weight: ",weight)

    # write it out to csv file
    with open('weight.txt', 'a') as outfile:
        outfile.write(weight) 

    # put in reverse chronological order using linux tac
    with open('revweight.txt', 'w') as outfile:
        subprocess.run(['tac', 'weight.txt'], stdout=outfile)


if __name__ == "__main__":

    if len(sys.argv) < 2:
        print("no argument passed")
        weight = input("Enter weight: ")
        get_weight(weight)
    else:
        get_weight(sys.argv[1])