2

Is there a way to export an org-mode table to a file without running the interactive org-table-export command from emacs?

I often use org-mode to create tables that I then export either to latex for inclusion in my main latex file or to csv for import into R for further processing.

I suspect that this could all be handled using a dynamic document that uses org-babel. But I find keeping R code and text separate and using make simpler, so would like way to export these tables programmatically so that I could make sure the latest version is updated before compiling my final text or running my R analysis.

So I'm looking for a way to run org-table-export on a specified file from the shell (that way I could put it in a makefile or in an R script).

I think I can run an elisp function from the command line using --batch --eval like here: https://stackoverflow.com/a/11475245/1072349, but I don't know enough elisp to write the function to pass a file to org-table-export.

Community
  • 1
  • 1
ajerneck
  • 751
  • 1
  • 7
  • 19

1 Answers1

2

From looking into org-table-export the following should work:

(defun my-export-batch-function (my-org-file pos-inside-my-table my-org-table-saved-file)
  (find-file my-org-file)
  (goto-char pos-inside-my-table)
  (org-table-export my-org-table-saved-file))

Remains the Emacs batch-mode part

Andreas Röhler
  • 4,804
  • 14
  • 18