Habit tracker table and section summary generator from daily notes

Hi guys, not sure if this would be useful to anyone else but I wrote a python script to generate summary pages from historical daily notes by entries under each header, including a table to summarise e.g. tracked habits.

Demo: If your daily entries are generated from a template with set headers and look something like this:

The scripts generate summary reports like the following:

This might be useful if you have a template with set sections for your daily entries or use it “bullet journal” style and would like to see all the entries you made for each section.

There’s an option to use full transclusion if you want to edit in the summary page (e.g. check to-dos) and have it reflected back on the original daily note, or just want easy backlink navigation which is always handy. You can turn this off if you just want a summarised diary entry for a prettier view.

You do have to run the python file to generate these summaries and won’t update automatically with new daily entries, but there are ways to automate the scripts to run every day (e.g. using crontab on mac), I’ve added an example bash script I use to do everything in one go.

I wrote this script for fun but maybe this functionality already exists and I just don’t know about it - I only found out about Obsidian recently (loving it so far!) and don’t know the full extent of the functionalities it offers. So if there is an “official” way to look at summaries by header please do let me know since using that is probably better haha.

Some limitations:

  • I haven’t tested this extensively (tested on URL and [[page links]]), feel free to play around and send PRs

  • Habit tracking only works for check boxes for now (but the code should be able to eventually adapt to habits tracked with numbers as well)

  • Code could definitely be refactored e.g. some hard-coding going on with string partitioning etc. (I’m not experienced in handling html and markdown in python…) :slight_smile:

  • Known bugs (20/2/21): non-translusion display doesn’t work properly if you have a # tag right after a bullet point.

Here’s the code: GitHub - risaueno/obsidian_scripts

23 Likes

hi i am a complete beginner in obsidian and python but i find this code interesting ! could you kindly tell me how can i apply it to my obsidian ?

Hey just found this post! Super helpful thank you for sharing!

Hi I’m new in Obsidian and Python but I was able to run the script, it’s amazing thank you so much for sharing!

I have a suggestion/request: in the mood tracker is there a way to show the emoticon in each day cell instead of the tick mark? I use colours instead of emojis for my mood tracker so it would be cool to have in the summary a table that is completely coloured.
Hope I was clear. In the summary table instead of the tick, show the emoji for that day.

Thank you so much!

Hey! This is exactly what I’m looking for. However, I have no idea about python and how to get this working - is there somewhere I can learn please? Thanks for your work.

I am not the OP but you should be able to get it running something like this:

  • Go to the Python website to get a Python installer. Install Python on your computer.
  • Python is a command-line program. You’ll need to follow the instructions at the OP’s linked github to run the python script. You’ll mostly be typing the commands they specify into a console program (such as “Command Line” on a Windows PC; you can run Command Line from your Start Menu; you can type “cmd” to find and open it).

I haven’t tried running this myself (though I’m interested); I just know that this is generally what you’ll need to do.

1 Like

@looper

So wanted to hopefully save some people from going down the wrong rabbit hole so hopefully this helps.

A) Python is not a command line program - it is an object-oriented programming language, in simplest of terms - Python is a diverse coding language that can do a lot of different stuff - from making a game to something simple like an automation script.

B) In light of A, we realize that it probably won’t be as simple as just downloading python onto your computer. What about which version? Is this compatible with the most recent python.10 or will you need to run an older version? When you download Python, it is not like downloading an app. You have to make sure Python is added to your path. (99% of people have 0 idea what anybody is talking about when you say “add python to your path”)

btw, they’ve made it so you can click a box when installing to indeed add python to your path - but how would
anyone be aware of this?

C) In relation to this post and project (very cool btw) - you need to install 3 different dependencies, and to do that, well now we need to learn, “what the heck is ‘pip’ ?”

then you need to edit the python file, what are you going to edit the python file with?
Oh now let’s teach you about VsCode, or maybe you like Sublime Text, or maybe Atom? or Obsidian?

D) Working with GitHub :smiling_imp: - seems simple enough right? So everyone knows what a pull request is, forking a repo, cloning, etc etc.

Hopefully this clears up some questions, highlights why authors of these posts cannot possibly have the time to respond or even know where to begin on setting this up for someone with zero knowledge.

To be clear - none of this stuff is Nuclear Physics and is understandable but as you see - there’s layers to this shit.

1 Like

@4x3L Excellent clarification; thank you.

Looks great! Was curious if anyone knew of a way this could be done with Dataview? i.e. Dataview query that lists all strings under the similar headings in Daily Notes (assuming Daily notes are templated)

1 Like

Possibly! Dataview works on an inline key-value system rather than “under headings”. If you’re looking at things “under headings” the built-in Obsidian search, for which you can embed queries in codeblocks like you can with dataview, may be more helpful!

For more specific guidance, you might try making a new thread explaining what your daily note template would look like and what pieces of it you are trying to query.

Thanks for the response! I was able to figure it out and will document it here in case it might help someone else:

I use a Daily Note template that has a section with the parameters I want to track in my “Dashboard Note”. The section is setup like this:

HABITS

[Wake Early :: hh:mm]
[Gym :: :white_check_mark:]
[Study :: :white_check_mark:]
[Afternoon Walk :: :heavy_minus_sign:]

Then in my Dashboard Note, I have a dataview query as follows:

TABLE WITHOUT ID
	link(file.name) as "Habit Log",
	wake-early AS "🌤️",
	gym AS "🏋️‍♂️",
	study AS "📗",
	afternoon-walk AS "🏃‍♀️"
	FROM "_Periodic/01 Daily"
	SORT file.name DESC
	LIMIT 10
	WHERE file.name != "01 Daily"

Note that the parameter after FROM above should be the folder location of your Daily Notes. You can also edit the LIMIT number to however many rows you want the query to display.

Hope this helps someone implement a tabular habit tracker that pulls from Daily Notes thru Dataview!