From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andreas Leha Subject: Re: Use babel to import table data from OpenDocument spreadsheets? Date: Wed, 10 Jul 2013 23:31:06 +0200 Message-ID: <87d2qqrtk5.fsf@med.uni-goettingen.de> References: <87k3l9kq78.wl%jamshark70@dewdrop-world.net> <878v1pvybk.fsf@gmail.com> <87y59p591f.wl%jamshark70@dewdrop-world.net> <87y59p80b3.fsf@gmail.com> <87vc4s5q0o.wl%jamshark70@dewdrop-world.net> <87ip0j5f8q.wl%jamshark70@dewdrop-world.net> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43463) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ux1yr-0006Ql-OH for emacs-orgmode@gnu.org; Wed, 10 Jul 2013 17:31:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ux1yq-0004Gm-8d for emacs-orgmode@gnu.org; Wed, 10 Jul 2013 17:31:21 -0400 Received: from plane.gmane.org ([80.91.229.3]:47612) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ux1yq-0004Gh-2k for emacs-orgmode@gnu.org; Wed, 10 Jul 2013 17:31:20 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1Ux1yp-0006Hu-7R for emacs-orgmode@gnu.org; Wed, 10 Jul 2013 23:31:19 +0200 Received: from 84.121.221.93.dyn.user.ono.com ([84.121.221.93]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 10 Jul 2013 23:31:19 +0200 Received: from andreas.leha by 84.121.221.93.dyn.user.ono.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 10 Jul 2013 23:31:19 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi James, James Harkins writes: > At Wed, 03 Jul 2013 10:35:51 +0800, > James Harkins wrote: >> Anyway, I'm not convinced that org-odt-convert would meet my needs >> anyway. It will have to be a multi-worksheet file, and I'll have to >> extract just one or two of the worksheets. The macro might be the >> way to go. > > I've made a bit more progress with this. I found a utility, > unoconv[1], which I can persuade to produce a tab-separated export of > the first worksheet of an ODS document. That much should work for my > needs -- I can reserve the first worksheet for the data to be > published, and put all the calculations in other sheets. > > I'm not sure how to import this as an org table. I found > org-table-import, but it seems that this must insert a table into a > buffer and then convert to org-table format in the buffer. I don't > know how to integrate that with babel. If I set ":exports results," > should I assume then that the code block should return a string > consisting of the org-formatted table? > > - Or, do I have to say ":exports none" and do some save-excursion > magic with moving the point to the right place before calling > org-table-import? (That's probably okay for this small-scale usage, > but it would be slicker to put a #+CALL in the right location.) > > - Or, do I have to write my own lisp function to format the table as a string? > > The goal is that I should be able to do C-c C-e h h from the org > document, and babel will run a short emacs-lisp block to invoke > unoconv (producing a CSV file on disk) and then insert the table under > the right heading. > > Thanks, > hjh > > [1] http://linux.die.net/man/1/unoconv I did not follow the thread, but reading ods files into org is easy, if you have access to R: --8<---------------cut here---------------start------------->8--- #+name: firstsheet #+begin_src R :colnames yes library("ROpenOffice") read.ods("~/tmp/not.ods")[[1]] #+end_src #+results: firstsheet | first col | second col | third col | |-----------+------------+-----------| | 8 | 4 | 5 | | 1541 | 79 | 628 | #+name: secondsheet #+begin_src R :colnames yes library("ROpenOffice") read.ods("~/tmp/not.ods")[[2]] #+end_src #+results: secondsheet | dtr | egd | pdrn | |-------+-------+------| | ugn | apggh | gpd | | ulgnd | pugn | pdsg | --8<---------------cut here---------------end--------------->8--- Regards, Andreas