Hi John,

John Kitchin <jkitc...@andrew.cmu.edu> 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!


Reply via email to