final commit
This commit is contained in:
@@ -129,6 +129,8 @@ diet_csv = [[
|
||||
'saturated_fat', 'sugar', 'fiber'
|
||||
]]
|
||||
|
||||
output = open('diet', 'w')
|
||||
|
||||
for fpath in sorted((Path.home() / 'workspace' / 'journal').glob('*.md')):
|
||||
day = fpath.stem
|
||||
header, *tmp = entry_re.split(fpath.read_text())
|
||||
@@ -143,6 +145,7 @@ for fpath in sorted((Path.home() / 'workspace' / 'journal').glob('*.md')):
|
||||
daily_sugar = 0.0
|
||||
|
||||
for (timestamp, content) in sorted(entries, key=lambda x: x[0]):
|
||||
ts_str = timestamp
|
||||
timestamp = int(datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S').timestamp())
|
||||
|
||||
content = '\n'.join(
|
||||
@@ -152,8 +155,11 @@ for fpath in sorted((Path.home() / 'workspace' / 'journal').glob('*.md')):
|
||||
|
||||
for diet in diet_re.finditer(content):
|
||||
value, name = diet.groups()
|
||||
output.write(f'{ts_str} {name} {value}\n')
|
||||
|
||||
value = float(value.removesuffix('g'))
|
||||
|
||||
|
||||
if name in recipes:
|
||||
food = recipes[name]
|
||||
|
||||
@@ -171,6 +177,7 @@ for fpath in sorted((Path.home() / 'workspace' / 'journal').glob('*.md')):
|
||||
print(f'ERROR: Invalid diet entry: {content}')
|
||||
continue
|
||||
|
||||
|
||||
|
||||
diet_csv.append((
|
||||
timestamp,
|
||||
|
||||
Reference in New Issue
Block a user