emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to export table from a src block?
@ 2016-03-28 19:10 William Denton
  2016-03-28 19:20 ` John Kitchin
  0 siblings, 1 reply; 2+ messages in thread
From: William Denton @ 2016-03-28 19:10 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: TEXT/PLAIN, Size: 574 bytes --]

I have a big table (with #+NAME: mytable).  I can export it to a CSV file by 
hand by having the point somewhere in the table and running

M-x org-table-export

but how could I do this from a source block?  I've got one line so far, but how 
would I get it to be in the table when it runs?  There's nothing else in this 
file, just a table and then this source block.

#+BEGIN_SRC emacs-lisp
(org-table-export "/tmp/mytable.csv" "orgtbl-to-csv")
#+END_SRC

Any help appreciated!

Bill
-- 
William Denton ↔  Toronto, Canada ↔  https://www.miskatonic.org/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to export table from a src block?
  2016-03-28 19:10 How to export table from a src block? William Denton
@ 2016-03-28 19:20 ` John Kitchin
  0 siblings, 0 replies; 2+ messages in thread
From: John Kitchin @ 2016-03-28 19:20 UTC (permalink / raw)
  To: William Denton; +Cc: emacs-orgmode

Try this:

* Export table from src-block

#+name: mytable
| a | b |
| 1 | 2 |
| 3 | 4 |


#+BEGIN_SRC emacs-lisp
(save-excursion
  (org-open-link-from-string "[[mytable]]")
  (while (not (org-table-p)) (forward-line))
  (org-table-export "mytable.csv" "orgtbl-to-csv"))
#+END_SRC
#+RESULTS:
: Export done.

#+BEGIN_SRC sh
cat mytable.csv
#+END_SRC
#+RESULTS:
: a,b
: 1,2
: 3,4



William Denton writes:

> I have a big table (with #+NAME: mytable).  I can export it to a CSV file by
> hand by having the point somewhere in the table and running
>
> M-x org-table-export
>
> but how could I do this from a source block?  I've got one line so far, but how
> would I get it to be in the table when it runs?  There's nothing else in this
> file, just a table and then this source block.
>
> #+BEGIN_SRC emacs-lisp
> (org-table-export "/tmp/mytable.csv" "orgtbl-to-csv")
> #+END_SRC
>
> Any help appreciated!
>
> Bill


--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-03-28 19:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-28 19:10 How to export table from a src block? William Denton
2016-03-28 19:20 ` John Kitchin

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).