Found a great habit tracker for Obsidian but unsure how to implement it using python - any advice?

This is exactly what I’m looking for as a daily habit tracker, per James Clear, but the use of python and github are beyond my current competency.

Could anyone please point me in the direction for learning how to work with python in this way? Thanks!

1 Like

It does indeed look like a very nice solution. However, it will not work on mobile devices etc, right?

The thing is, you can get very similar functionality via Dataview plugin. That is what I use for my habit tracking.

I set the things I wish to track in the YAML front-matter of my daily notes (but you could, like in your example, set those things directly in the body of the daily file too).

I then extract that tracking data in my weekly note, at the very top of it. I usually have my daily note and my weekly note open at the same time, next to each other. I haven’t used it for a full whole month yet, but the intention is to extract it all to a monthly summary as well, and I see no reason to why it wouldn’t work.

It looks like this (with my daily note to the left and my weekly note to the right):

Obviously the weekly note contains more things below that habit-tracking table.

The nice thing with using habit tracking via Dataview is, apart from that it works on all my devices, that it is real-time updated. I don’t have to run any external script to make it work.

Just a thought. It’ll be a lot quicker than learning Python for sure. :slight_smile:

6 Likes

I’m not sure how is the script exactly written, but python is usable on Android devices though different IDEs or Termux. iOS devices also have a lot of choices on the App Store.

That is probably correct, I haven’t explored the “how” regarding running Python scripts on my iOS devices to be honest. Never had the need for it. I still fail to see the obvious benefit of jumping through the hoops and barriers of learning and then running Python, compared to using Dataview plugin directly in Obsidian for this type of functionality, but hey, that is on me, I might well be missing something obvious.

Okay, thanks for this, it looks great and precisely what I’m looking for. Would you be able to share a little more about how to achieve this please?

I already have the Dataview plugin, but after that I’m a bit lost!

Yeah, sure.

Firstly I have a couple of tags in literally all my notes. Several of them are date based, to make it easy to find notes from a specific day, week or month. The Templater plugin creates 99% of my notes, but how you create them, and how you tag them otherwise, is irrelevant. For my habit tracking they are needed though.

I keep all my daily notes in a folder of my “inbox” folder, called “journal”. There I also file my daily/weekly notes in to subfolders per month (i.e. 202110 right now) when their time has passed.

This is what my YAML front matter (at the very top of the file) of a Daily note looks like:

---
uid: 202110140016 
aliases: Thu Oct 14
tags: daily_note 20211014 2021-W41 2021-10 refile double_click_me 
weekday: Thu
medicine: 🟩
thm-login: 🟩
eve-login: 🟥
push-ups: 🟧
write500words: 🟥
call-mum: 🟥
running: 🟥
apply-for-2-jobs: 🟥
---

As you can see I am using emojis for indicating status. They all default to “red_square” and then I change their state as I do my habits. On the topic of emoticons I can recommend the plugin Emoji Toolbar as well as the Emoji Shortcodes plugin, as it makes it even faster to do these things (less barriers is a good thing).

For my top habits I intend to do them on a daily basis, with the final three I actually aim to do them either “every third day” or “weekly”.

I denote partial success as red → orange → yellow → green (push-ups for example, I do 20x3 over a day at the moment, so I can keep track of where I am at).

None of the YAML front matter is visible in preview mode of the daily note, it is only visible in edit mode. I could obviously chose to show it in the Daily note too, but I often have both of them open at the same time anyways, and having it once on my screen is enough for me.

Then in my weekly note I have the following front matter and the dataview code snippet:

---
uid: 202110110014
aliases: 2021 - W41
tags: weekly_note 2021-W41 2021-10
---

```dataview
TABLE WITHOUT ID
  weekday AS "Day",
  medicine AS "💊",
  thm-login AS "🔑",
  eve-login AS "🚀",
  push-ups AS "💪",
  write500words AS "🖊️",
  call-mum AS "📱",
  running AS "🏃‍♂️",
  apply-for-2-jobs AS "👨‍💼"
FROM "inbox/journal" and #2021-W41 and -#weekly_note
SORT file.ctime ASC
```

In my “journal” folder I only have the Daily, Weekly and Monthly Habit Tracker file for that month, apart from the filing folders for each month. Tomorrow I will move todays daily file (then yesterdays file) to the monthly filed folder. Keeps it orderly and neat, and dataview works recursively for all the subfolders of “inbox/journal” anyways, so it will not break.

The snippet above will create a table with emojis for the habits and emojis for the status, which means it will be neat and orderly there too.

That is it for the habit tracking really. It looks a lot longer/complicated when typing out the explanations like this in text, but the short version is: YAML front matter tags in Daily notes get extracted in the Weekly note, in a table, all using emojis. :slight_smile:

I also notice I really should shape up on my running. :rofl:

5 Likes

By the way, I don’t know if you have used Templater or not, but this is what my weekly template looks like for Templater. When I click the weeknumber in the Calendar plugin and it says “File doesn’t exist, would you like to create it?” and I go “Yeah, sure”, this is what it does (with relation to habit tracking…it does quite a bit more that isn’t relevant for this topic).

Weekly:

---
uid: <% tp.date.now("YYYYMMDDHHmm") %>
aliases: <% tp.date.now("gggg - [W]ww") %>
tags: weekly_note <% tp.date.now("gggg-[W]ww") %> <% tp.date.now("YYYY-MM") %>
---

```dataview
TABLE WITHOUT ID
  weekday AS "Day",
  medicine AS "💊",
  thm-login AS "🔑",
  eve-login AS "🚀",
  push-ups AS "💪",
  write500words AS "🖊️",
  call-mum AS "📱",
  running AS "🏃‍♂️",
  apply-for-2-jobs AS "👨‍💼"
FROM "inbox/journal" and #<% tp.date.now("gggg-[W]ww") %> and -#weekly_note
SORT file.ctime ASC
```

Conversely, this is that the YAML section looks like in the Daily note Templater file when I click that day in the Calendar and it doesn’t exist.

Daily:

---
uid: <% tp.date.now("YYYYMMDDHHmm") %> 
aliases: <% tp.date.now("ddd MMM D") %>
tags: daily_note <% tp.date.now("YYYYMMDD") %> <% tp.date.now("gggg-[W]ww") %> <% tp.date.now("YYYY-MM") %> refile double_click_me 
weekday: <% tp.date.now("ddd") %>
medicine: 🟥
thm-login: 🟥
eve-login: 🟥
push-ups: 🟥
write500words: 🟥
call-mum: 🟥
running: 🟥
apply-for-2-jobs: 🟥
---
5 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.