diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2010-08-08 22:23:53 -0600 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2010-08-08 22:23:53 -0600 |
commit | 25ac9ea8dda9fd1192fd13a2c0be5886115bacb1 (patch) | |
tree | 239f1387ba124f82f894bf48b9d07ad1e06113e7 | |
parent | 693cea9bb95f4eac41d9f1c97192c70cb0bd1263 (diff) | |
download | org-mode-25ac9ea8dda9fd1192fd13a2c0be5886115bacb1.tar.gz |
library-of-babel: more control over exporting results to files
#+source: table
#+begin_src emacs-lisp
(mapcar
(lambda (el) (number-sequence el (+ el 3)))
(number-sequence 0 4))
#+end_src
writes the results out as csv file
#+call: write(data=table, file="~/Desktop/example.csv") :results silent
writes the results out as tab separated file
#+call: write(data=table, file="~/Desktop/example.tsv") :results silent
write the results out as a normal org-mode file
#+call: write(data=table, file="~/Desktop/example.org") :results silent
* contrib/babel/library-of-babel.org: more control over exporting
results to files
-rw-r--r-- | contrib/babel/library-of-babel.org | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/contrib/babel/library-of-babel.org b/contrib/babel/library-of-babel.org index 41d9c41..d2b9ff2 100644 --- a/contrib/babel/library-of-babel.org +++ b/contrib/babel/library-of-babel.org @@ -46,9 +46,14 @@ file as either a table or a string. Write =data= to a file at =file=. If =data= is a list, then write it as a table in traditional Org-mode table syntax. #+srcname: write -#+begin_src emacs-lisp :var data="" :var file="" - (with-temp-file file - (org-babel-insert-result data)) +#+begin_src emacs-lisp :var data="" :var file="" :var ext='() + (flet ((echo (r) (if (stringp r) r (format "%S" r)))) + (with-temp-file file + (case (and (listp data) + (or ext (intern (file-name-extension file)))) + ('tsv (insert (orgtbl-to-tsv data '(:fmt echo)))) + ('csv (insert (orgtbl-to-csv data '(:fmt echo)))) + (t (org-babel-insert-result data))))) nil #+end_src |