From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: getting an hline in a python generated table Date: Fri, 03 Apr 2015 16:47:44 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:48272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ye8VK-0008Bq-0R for emacs-orgmode@gnu.org; Fri, 03 Apr 2015 16:47:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ye8VG-0004ML-QB for emacs-orgmode@gnu.org; Fri, 03 Apr 2015 16:47:49 -0400 Received: from smtp.andrew.cmu.edu ([128.2.157.38]:42575) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ye8VG-0004MD-Lw for emacs-orgmode@gnu.org; Fri, 03 Apr 2015 16:47:46 -0400 In-reply-to: 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: William Henney Cc: Orgmode Mailing List wow, that is some wizardry there! I did not know you could do a return value that way! or get an hline from None! thanks! William Henney writes: > A simpler solution is to just use None, which gets automatically converted > to an hline by org-babel: > > #+BEGIN_SRC python :return mytable > NROWS, NCOLS = 6, 4 > mytable = [] > mytable.append(['A', 'B', 'C', 'D']) # Table header > mytable.append(None) # hline > for irow in range(NROWS): > mytable.append([icol**irow for icol in range(NCOLS)]) > mytable.append(None) # hline > #+END_SRC > > #+RESULTS: > | A | B | C | D | > |---+---+----+-----| > | 1 | 1 | 1 | 1 | > | 0 | 1 | 2 | 3 | > | 0 | 1 | 4 | 9 | > | 0 | 1 | 8 | 27 | > | 0 | 1 | 16 | 81 | > | 0 | 1 | 32 | 243 | > |---+---+----+-----| > > Will > > > On Wed, Apr 1, 2015 at 2:07 PM, John Kitchin > wrote: > >> Hi everyone, >> >> 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? >> >> thanks, >> >> -- >> 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 >> >> -- 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