From: John Kitchin <jkitchin@andrew.cmu.edu>
To: William Henney <whenney@gmail.com>
Cc: Orgmode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: getting an hline in a python generated table
Date: Fri, 03 Apr 2015 16:47:44 -0400 [thread overview]
Message-ID: <m2ioddj5vz.fsf@andrew.cmu.edu> (raw)
In-Reply-To: <CAKchnZPkr7SSL5d3W5hZ4zxYbehrLA_Bz16ZYMrO=VRZzF8sYg@mail.gmail.com>
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 <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))
>> '(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
prev parent reply other threads:[~2015-04-03 20:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-01 20:07 getting an hline in a python generated table John Kitchin
2015-04-01 20:50 ` Rasmus
2015-04-03 18:44 ` Ken Mankoff
2015-04-03 18:46 ` Ken Mankoff
2015-04-03 20:18 ` John Kitchin
2015-04-03 20:42 ` William Henney
2015-04-03 20:47 ` John Kitchin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2ioddj5vz.fsf@andrew.cmu.edu \
--to=jkitchin@andrew.cmu.edu \
--cc=emacs-orgmode@gnu.org \
--cc=whenney@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.