From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rasmus Subject: Re: getting an hline in a python generated table Date: Wed, 01 Apr 2015 22:50:48 +0200 Message-ID: <87d23nshcn.fsf@gmx.us> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdPbQ-0003z7-3z for emacs-orgmode@gnu.org; Wed, 01 Apr 2015 16:51:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YdPbM-0006h5-Kn for emacs-orgmode@gnu.org; Wed, 01 Apr 2015 16:51:08 -0400 Received: from plane.gmane.org ([80.91.229.3]:56679) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdPbM-0006gy-EM for emacs-orgmode@gnu.org; Wed, 01 Apr 2015 16:51:04 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YdPbI-0000t5-Sr for emacs-orgmode@gnu.org; Wed, 01 Apr 2015 22:51:00 +0200 Received: from tsn109-201-154-169.dyn.nltelcom.net ([109.201.154.169]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 01 Apr 2015 22:51:00 +0200 Received: from rasmus by tsn109-201-154-169.dyn.nltelcom.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 01 Apr 2015 22:51:00 +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 John, John Kitchin writes: > In emacs-lisp, I can get a table as output that has a horizontal line > in it like this: > > (append '((name scopus-id h-index n-docs n-citations)) > '(hline) > (some expression that generates a list)) > > The first row is header names, then a horizontal line, followed by a row > for each thing of interest. This seems to work because the result is an > emacs-lisp "array". > > I cannot figure out if this is possible in a Python block though. So far > my experiments have failed because I don't know how to make an hline > symbol in a Python array. Any kind of string just shows as a row. Any > thoughts on if this is possible? I'd be lazy and just use the :post argument. So something like the following. I'm pretty sure I once wrote a :post function that took negative number (to add a final hline), but I couldn't find it... #+BEGIN_SRC python :post add-hline(tbl=*this*) return([ ["a"], [1], [2]]) #+END_SRC #+RESULTS: |---| | a | |---| | 1 | | 2 | #+name: add-hline #+BEGIN_SRC emacs-lisp :var tbl='((a) (b) (c)) hlines='(0 1) (loop for hline in (mapcar* '+ hlines (number-sequence 0 (length hlines))) do (setq tbl (append (subseq tbl 0 hline) '(hline) (subseq tbl hline)))) tbl #+END_SRC Hope it helps, Rasmus -- With monopolies the cake is a lie!