From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz Subject: Re: Insert a line separator in table results Date: Thu, 17 Jul 2014 00:54:25 +0200 Message-ID: <8761iwc3tq.fsf@gmail.com> References: <53C6CD37.1030602@gmail.com> <87fvi1azej.fsf@gmail.com> <53C6F913.90307@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7Y65-0004V6-2G for emacs-orgmode@gnu.org; Wed, 16 Jul 2014 18:54:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X7Y5x-000765-IS for emacs-orgmode@gnu.org; Wed, 16 Jul 2014 18:54:49 -0400 Received: from plane.gmane.org ([80.91.229.3]:58523) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7Y5x-000761-BM for emacs-orgmode@gnu.org; Wed, 16 Jul 2014 18:54:41 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1X7Y5v-0007lX-Ro for emacs-orgmode@gnu.org; Thu, 17 Jul 2014 00:54:39 +0200 Received: from g231233164.adsl.alicedsl.de ([92.231.233.164]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 17 Jul 2014 00:54:39 +0200 Received: from tjolitz by g231233164.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 17 Jul 2014 00:54:39 +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 Xavier Garrido writes: Hi Xavier, > I would like to be able to do it with =python=... Maybe it is only > possible with =emacs-lisp= as you suggest. I don't know python and cannot try it out here either ... but it should be exactly the same thing: build and return a list that consists of lists (each table row one list) and 'hline symbols (each hline one separator line). Does python have lists and symbols? The latter probably not... This could be your strategy: 1. build and return a string in (named) python src-block that contains a 'table-list' (rows and hlines) 2. use that python-src-block as var for and elisp src-block: #+header: :var lst=myPythonBlock 3. read-from-string that list in emacs-lisp (read-from-string lst) 4. return the car from the result in source-block #+name: myPythonBlock #+begin_src emacs-lisp # should be python (concat "((1 2 3) hline (4 5 6)" " (a b c) hline (e f g))") #+end_src #+results: myPythonBlock : ((1 2 3) hline (4 5 6) (a b c) hline (e f g)) #+header: :var lst=myPythonblock #+begin_src emacs-lisp :results table (car (read-from-string lst)) #+end_src #+results: | 1 | 2 | 3 | |---+---+---| | 4 | 5 | 6 | | a | b | c | |---+---+---| | e | f | g | but maybe a python programmer can tell you how to do it directly from python. > Le 16/07/2014 21:15, Thorsten Jolitz a écrit : >> Xavier Garrido writes: >> >>> Dear orgers, >>> >>> I would like to programmatically insert a line separator when generating >>> a table result. Below is a minimal working example with =python= >>> src block >>> >>> #+BEGIN_SRC python >>> x = [("label 1", "label 2", "label 3"), ("-", "-", "-")] >>> x.append((4, 5, 6)) >>> x.append((7, 8, 9)) >>> return (x) >>> #+END_SRC >>> >>> #+RESULTS: >>> | label 1 | label 2 | label 3 | >>> | - | - | - | >>> | 4 | 5 | 6 | >>> | 7 | 8 | 9 | >>> >>> Is there any possibility to interpret dash as line separator ? >> >> #+begin_src emacs-lisp :results table >> (list '(1 2 3) 'hline '(a b c) '(d e f) 'hline '(4 5 6)) >> #+end_src >> >> #+results: >> | 1 | 2 | 3 | >> |---+---+---| >> | a | b | c | >> | d | e | f | >> |---+---+---| >> | 4 | 5 | 6 | -- cheers, Thorsten