Like many people, Simon Pugnet likes to keep a record of his exercising. His regime includes several types of exercise such as running, sit-ups, and pushups. Also like many of us, he maintains a daily journal so, of course, it made sense to record the exercising in his (Org mode) journal. He does this by adding a third level headline for each exercise under the second level headline Exercises
. The first level headlines are the date so this gives Pugnet an “Exercises” headline for each day.
You may not think this is an optimal setup but it’s a reasonable one. Now, however, Pugnet wanted to generate a table of his daily exercise and maybe even some graphs. He solved that by writing a bit of Elisp, which you can see in his blog post about his setup. It would certainly have been easier to record the data in an Org table to begin with, which is what I do for things like this but I do like the idea of keeping everything in the journal and extracting the data you need for whatever project you’re working on. It take a little more work but everything is in one place and easy to find.
In any event, the reason I’m writing about this is that Pugnet’s code is a nice illustration of how to parse Org files and extract data from the entries. You can, of course, do that with regular expression search and other ad hoc methods but Org provides you with functions that take care of all that for you. It’s worth studying Pugnet’s post just to get an idea of how to do these things.