3

With clock reports, one can set :step day, and then I have a list of totals by day. Like:

#+BEGIN: clocktable :tstart "<-1w>" :tend "<+1d>" :step day :scope ("dev.org" "tst.org") :maxlevel 1 :narrow 65
| File      | Headline                                                          | Time   |
|-----------+-------------------------------------------------------------------+--------|
|           | ALL *Total time*                                                  | *6:38* |
|-----------+-------------------------------------------------------------------+--------|
| dev.org   | *File time*                                                       | *3:04* |
| tst.org   | *File time*                                                       | *3:34* |

But it's quite verbose, lots of info. I'd like a summary.

I'd like to post-process that list so that I have the total productivity by day, like:

[2015-02-19 Thu] 6:38  (Dev.org 3:00, testing.org 3:20)  
[2015-02-20 Fri] 5:03  (Dev.org 3:00, testing.org 2:03)  
[2015-02-21 Sat] 4:30  (Dev.org 2:00, testing.org 2:30)

I'm willing to write some code to maybe grep out the relevant bits and glue it all together.

But I'm kinda wondering, how do I go about starting something like this? I.e, what would be the building blocks?

Can I use like the :formatter property with some function? or can I use bable to post-process this with some bash/grep/awk/sed/cut, or with python?

[edit] A bash solution.. So far I've hacked myself something together with bash.

I generate a report as above. Then export it into ascii into report.txt. Then I use a bash script:

cat ~/git/LeoUfimtsev.github.io/org/reports.txt | egrep 'Daily|Total' | tr -d '[[:space:]]' | sed 's/Daily/\nDaily/g' | sed 's/\*Totaltime\*\*/ /g' | sed 's/Dailyreport://g' | sed 's/ALL/ /g' | sed -E -e 's/Thu|Fri|Sat|Sun|Mon|Tue|Wed|\*//g'

And then I get something like this:

  37:47
2015-02-19  6:42
2015-02-20  4:02
2015-02-21  0:00
2015-02-22  2:55
2015-02-23  4:09
2015-02-24  4:37

Now I just have to automate things.

  • open report.org buffer
  • export to ascii
  • run bash script
  • show output somewhere
  • Plot onto chart :-D

I think these are probably straight-forward enough for me to tacke on my own thou. That said, if anyone has any better advice, I'm open to suggestions.

3

Regarding the sub-question: Can I use like the :formatter property with some function? or can I use bable to post-process this with some bash/grep/awk/sed/cut, or with python?

You can post-process a clocktable by naming it and then referencing it using babel:

#+BEGIN: clocktable :properties ("CLOCK") :header "#+NAME: clocked\n"
#+NAME: clocked

#+END:

#+begin_src emacs-lisp :var clocked=clocked :results table
(cl-loop for row in (subseq clocked 4) ; skip headers
         collect (list (org-parse-time-string (nth 0 row))
                       (org-duration-string-to-minutes (nth 2 row))))
#+end_src

#+NAME: clocked-b
#+RESULTS:
| (0 48 23 26 2 2015 nil nil nil) | 19 |
| (0 42 23 26 2 2015 nil nil nil) |  6 |
| (0 9 22 26 2 2015 nil nil nil)  |  3 |
| (0 6 22 26 2 2015 nil nil nil)  |  2 |
| (0 2 22 26 2 2015 nil nil nil)  |  4 |
| (0 55 21 26 2 2015 nil nil nil) |  7 |
| (0 41 21 26 2 2015 nil nil nil) | 13 |

You'll need to figure out the aggregating...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.