From mboxrd@z Thu Jan 1 00:00:00 1970 From: William Henney Subject: Re: getting an hline in a python generated table Date: Fri, 3 Apr 2015 14:42:42 -0600 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=bcaec5196bd36e34fc0512d7fd1f Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ye8QP-0006Su-Bl for emacs-orgmode@gnu.org; Fri, 03 Apr 2015 16:42:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ye8QO-0002Q0-36 for emacs-orgmode@gnu.org; Fri, 03 Apr 2015 16:42:45 -0400 Received: from mail-ig0-x22d.google.com ([2607:f8b0:4001:c05::22d]:36512) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ye8QN-0002PR-Td for emacs-orgmode@gnu.org; Fri, 03 Apr 2015 16:42:44 -0400 Received: by igblo3 with SMTP id lo3so13614700igb.1 for ; Fri, 03 Apr 2015 13:42:42 -0700 (PDT) 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: John Kitchin Cc: Orgmode Mailing List --bcaec5196bd36e34fc0512d7fd1f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 =3D 6, 4 mytable =3D [] 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 > > --=20 Dr William Henney, Centro de Radioastronom=C3=ADa y Astrof=C3=ADsica, Universidad Nacional Aut=C3=B3noma de M=C3=A9xico, Campus Morelia --bcaec5196bd36e34fc0512d7fd1f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
A simpler solution is to just use None, which gets automat= ically converted to an hline by org-babel:=C2=A0

#+= BEGIN_SRC python :return mytable
=C2=A0 NROWS, NCOLS =3D 6, 4
=C2=A0 mytable =3D []
=C2=A0 mytable.append(['A', = 'B', 'C', 'D']) =C2=A0# Table header
=C2= =A0 mytable.append(None) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0# hline
=C2=A0 for irow in range(NROWS):
= =C2=A0 =C2=A0 =C2=A0 mytable.append([icol**irow for icol in range(NCOLS)])<= /div>
=C2=A0 mytable.append(None) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0# hline=C2=A0
#+END_SRC

=
#+RESULTS:
| A | B | =C2=A0C | =C2=A0 D |
|-= --+---+----+-----|
| 1 | 1 | =C2=A01 | =C2=A0 1 |
| 0 |= 1 | =C2=A02 | =C2=A0 3 |
| 0 | 1 | =C2=A04 | =C2=A0 9 |
| 0 | 1 | =C2=A08 | =C2=A027 |
| 0 | 1 | 16 | =C2=A081 |
<= div>| 0 | 1 | 32 | 243 |
|---+---+----+-----|

Will


<= div class=3D"gmail_quote">On Wed, Apr 1, 2015 at 2:07 PM, John Kitchin <jkitchin@andrew.cmu.edu> 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))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 '(hline)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (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://kitc= hingroup.cheme.cmu.edu




--

=C2=A0 Dr William Henney, Centro de Radioastronom= =C3=ADa y Astrof=C3=ADsica,
=C2=A0 Universidad Nacional Aut=C3=B3noma de= M=C3=A9xico, Campus Morelia
--bcaec5196bd36e34fc0512d7fd1f--