On 13/08/2021 21:17, Roger Mason wrote:

I need to extract a column from a table to use as input to a source
block.  I want the extracted column to be returned as a column but it is
returned as a row.  The following illustrates the problem:

#+name: s1
| scale |  scale1 |   scale3 |  jid |
| -     | 1.00402 | 0.952329 | 1632 |
| -     | 1.00402 | 0.962247 | 1633 |

#+begin_src emacs-lisp :var data=s1[,3]
data
#+end_src

#+RESULTS:
| jid | 1632 | 1633 |

I want:

|  jid |
| 1632 |
| 1633 |

Is there some means of changing 'data=s1[,3]' to accomplish this?

Notice that you can get vertical representation of results as a list
#+begin_src emacs-lisp :results list

The following is a variation of a recipe suggested by Juan Manuel:

#+name: to-column
#+begin_src emacs-lisp :var lst=()
  (mapcar #'list lst)
#+end_src

#+begin_src emacs-lisp :var data=s1[,3] :post to-column(lst=*this*)
  data
#+end_src

To transform more than one column, the following idea may be useful

(defun rotate (list-of-lists)
  (apply #'mapcar #'list list-of-lists))

https://stackoverflow.com/questions/3513128/transposing-lists-in-common-lisp


Reply via email to