diff options
author | Eric Schulte <schulte.eric@gmail.com> | 2010-07-20 11:49:55 -0700 |
---|---|---|
committer | Eric Schulte <schulte.eric@gmail.com> | 2010-07-20 11:49:55 -0700 |
commit | 15ca30bc8664688090cd0861df6c9c8eed623698 (patch) | |
tree | ecb821ee14e626d3757397c7b6795bae65847eb5 | |
parent | 73d8016e8b1ceda75079f14847fd47d793e02c78 (diff) | |
download | org-mode-15ca30bc8664688090cd0861df6c9c8eed623698.tar.gz |
library-of-babel: improving reading text/tables in from files
* contrib/babel/library-of-babel.org(read): adding explicit format
argument
(gdoc-read): explicit format argument, and passing the csv
specification through to org-table-import
also removing org example code blocks
-rw-r--r-- | contrib/babel/library-of-babel.org | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/contrib/babel/library-of-babel.org b/contrib/babel/library-of-babel.org index f7d2394..41d9c41 100644 --- a/contrib/babel/library-of-babel.org +++ b/contrib/babel/library-of-babel.org @@ -33,8 +33,8 @@ Read the contents of the file at =file=. The =:results vector= and =:results scalar= header arguments can be used to read the contents of file as either a table or a string. #+srcname: read -#+begin_src emacs-lisp :var file="" - (if (member "vector" result-params) +#+begin_src emacs-lisp :var file="" :var format="" + (if (string= format "csv") (with-temp-buffer (org-table-import (expand-file-name file) nil) (org-table-to-lisp)) @@ -82,14 +82,13 @@ The =google= command seems to be throwing "Moved Temporarily" errors when trying to download textual documents, but this is working fine for spreadsheets. #+source: gdoc-read -#+begin_src emacs-lisp :var title="example" - (let* ((format (if (member "vector" result-params) "csv" "txt")) - (file (concat title "." format)) +#+begin_src emacs-lisp :var title="example" :var format="csv" + (let* ((file (concat title "." format)) (cmd (format "google docs get --format %S --title %S" format title))) (message cmd) (message (shell-command-to-string cmd)) (prog1 (if (string= format "csv") (with-temp-buffer - (org-table-import (shell-quote-argument file) nil) + (org-table-import (shell-quote-argument file) '(4)) (org-table-to-lisp)) (with-temp-buffer (insert-file-contents (shell-quote-argument file)) @@ -99,15 +98,11 @@ for spreadsheets. For example, a line like the following can be used to read the contents of a spreadsheet named =num-cells= into a table. -#+begin_src org - ,#+call: gdoc-read(title="num-cells"") :results vector -#+end_src +: #+call: gdoc-read(title="num-cells"") A line like the following can be used to read the contents of a document as a string. -#+begin_src org - ,#+call: gdoc-read(title="loremi") :results scalar -#+end_src +: #+call: gdoc-read(title="loremi", :format "txt") ****** write a document to a Google docs Write =data= to a google document named =title=. If =data= is tabular @@ -129,15 +124,13 @@ normal document. #+end_src example usage -#+begin_src org - ,#+source: fibs - ,#+begin_src emacs-lisp :var n=8 - , (flet ((fib (m) (if (< m 2) 1 (+ (fib (- m 1)) (fib (- m 2)))))) - , (mapcar (lambda (el) (list el (fib el))) (number-sequence 0 (- n 1)))) - ,#+end_src - - ,#+call: gdoc-write(title="fibs", data=fibs(n=10)) -#+end_src +: #+source: fibs +: #+begin_src emacs-lisp :var n=8 +: (flet ((fib (m) (if (< m 2) 1 (+ (fib (- m 1)) (fib (- m 2)))))) +: (mapcar (lambda (el) (list el (fib el))) (number-sequence 0 (- n 1)))) +: #+end_src +: +: #+call: gdoc-write(title="fibs", data=fibs(n=10)) * Plotting code |