- Notifications
You must be signed in to change notification settings - Fork18
Export Emacs org-mode clock entries to CSV format.
License
atheriel/org-clock-csv
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
org-clock-csv
is an Emacs package that extracts clock entries from org filesand convert them into CSV format. It is intended to facilitate clocked timeanalysis in external programs.
You can alsoread the original blog post.
org-clock-csv
is available fromMELPA. Youcan also install it manually by cloning the repository and adding the file toyourload-path
.
In interactive mode, callingorg-clock-csv
will open a buffer with the parsedentries from the files inorg-agenda-files
, whileorg-clock-csv-to-file
willwrite this output to a file. Both functions take a prefix argument to readentries from the current buffer instead.
Both functions can also be called from lisp code to specify an explicit filelist argument.
There is anorg-clock-csv-batch-and-exit
command that is designed for use inbatch mode (essentially, scripting Emacs), which will write CSV content tostandard output (and then exit). Calling this function is similar to runningtests withert
:
$ emacs -batch -l path/to/org-clock-csv.el \ -f org-clock-csv-batch-and-exit \ "~/org/todo.org" \ > clock-entries.csv
The command accepts a file list as a series of command line arguments (there isonly one in the example, but more can be given), or uses the content oforg-agenda-files
if there are none. You may also want to pipe the output to afile, as in the example.
Since Emacs is running in batch mode, it will not load yourinit.el
file. Thishas two consequences: (1) anysetq
orcustomize
code you have written fororg
or for this package will not be loaded; and (2) Emacs has not been toldwhere your third-party packages are located. So this invokation will likely giveyou the following error:
Cannot open load file: No such file or directory, s
Since the third-partys
library is needed to runorg-clock-csv-batch
. Youcan resolve this issue in a few ways. If you don't mind using the defaultsettings oforg
and this package, the easiest is simply to letpackage.el
(which you are probably using already) handle your third-party packages, asfollows:
$ emacs -batch -l package --eval "(package-initialize)" \ -l org-clock-csv -f org-clock-csv-batch-and-exit \ "~/org/todo.org" \ > clock-entries.csv
Alternatively, you can just load your entireinit.el
file, which will make allof your usual customizations toorg
and this package:
$ emacs -batch -l "~/.emacs.d/init.el" \ -l org-clock-csv -f org-clock-csv-batch-and-exit \ "~/org/todo.org" \ > clock-entries.csv
(Beware that this method may write messages other than the CSV output to yourfile.)
Finally, you can simply write a little "shim" script, really a very slimmed-downversion of yourinit.el
file, that runs all of yoursetq
code fororg
andthis package and also sets up theload-path
(usingpackage.el
or anequivalent) so that Emacs can finds
andorg-clock-csv
, and call it asfollows:
$ emacs -batch -l path/to/my-shim.el \ -l org-clock-csv -f org-clock-csv-batch-and-exit \ "~/org/todo.org" \ > clock-entries.csv
If you are usingCask you can clonethe repository and runcask install
to install all the dependencies.To execute theorg-clock-csv-batch-and-exit
you can then simply run:
cask exec org-clock-csv <file> [files...]
Contributions are welcome in the form of pull requests, although the scope ofthis package is intended to be small. If you have an org file that fails toparse as expected, feel free to open an issue.
All code is available under the GPLv3, the same license as Emacs itself. See theLICENSE
file for details.
About
Export Emacs org-mode clock entries to CSV format.