mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 18:36:26 +00:00
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
This commit is contained in:
parent
693cea9bb9
commit
25ac9ea8dd
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue