backup
This commit is contained in:
24
analyze.py
24
analyze.py
@@ -119,7 +119,8 @@ total_words = 0
|
||||
word_frequency = Counter()
|
||||
|
||||
total_csv = [['day', 'entries', 'words']]
|
||||
daily_csv = [['day', 'entries', 'words', 'calories', 'protein']]
|
||||
daily_csv = [['day', 'entries', 'words', 'calories', 'carbs', 'fat', 'protein',
|
||||
'sugar']]
|
||||
entry_csv = [['timestamp', 'words']]
|
||||
words_csv = [['word', 'count']]
|
||||
|
||||
@@ -137,6 +138,9 @@ for fpath in sorted((Path.home() / 'workspace' / 'journal').glob('*.md')):
|
||||
daily_words = 0
|
||||
daily_calories = 0.0
|
||||
daily_protein = 0.0
|
||||
daily_carbs = 0.0
|
||||
daily_fat = 0.0
|
||||
daily_sugar = 0.0
|
||||
|
||||
for (timestamp, content) in sorted(entries, key=lambda x: x[0]):
|
||||
timestamp = int(datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S').timestamp())
|
||||
@@ -183,6 +187,9 @@ for fpath in sorted((Path.home() / 'workspace' / 'journal').glob('*.md')):
|
||||
|
||||
daily_calories += food.get('Energy', 0.0)
|
||||
daily_protein += food.get('Protein', 0.0)
|
||||
daily_fat += food.get('Fat', 0.0)
|
||||
daily_carbs += food.get('Carbs', 0.0)
|
||||
daily_sugar += food.get('Sugar', 0.0)
|
||||
|
||||
words = ''.join(
|
||||
c if c in string.ascii_letters+"'" else ' '
|
||||
@@ -196,8 +203,19 @@ for fpath in sorted((Path.home() / 'workspace' / 'journal').glob('*.md')):
|
||||
|
||||
entry_csv.append([timestamp, entry_words])
|
||||
|
||||
daily_csv.append([day, daily_entries, daily_words, daily_calories,
|
||||
daily_protein])
|
||||
daily_macros = daily_protein + daily_fat + daily_carbs
|
||||
|
||||
daily_csv.append([
|
||||
day,
|
||||
daily_entries,
|
||||
daily_words,
|
||||
round(daily_calories, 2),
|
||||
round(100 * (daily_carbs / daily_macros) if daily_carbs else 0, 2),
|
||||
round(100 * (daily_fat / daily_macros) if daily_fat else 0, 2),
|
||||
round(100 * (daily_protein / daily_macros) if daily_protein else 0, 2),
|
||||
round(daily_protein, 2),
|
||||
round(daily_sugar, 2)
|
||||
])
|
||||
|
||||
total_entries += daily_entries
|
||||
total_words += daily_words
|
||||
|
||||
Reference in New Issue
Block a user