emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Maxim Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: return column from table as a column
Date: Sat, 14 Aug 2021 19:10:14 +0700	[thread overview]
Message-ID: <sf8br8$90c$1@ciao.gmane.io> (raw)
In-Reply-To: <y655yw9mnse.fsf@mun.ca>

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



  parent reply	other threads:[~2021-08-14 12:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13 14:17 return column from table as a column Roger Mason
2021-08-13 14:30 ` Greg Minshall
2021-08-13 16:24   ` Roger Mason
2021-08-13 18:47   ` Greg Minshall
2021-08-13 14:47 ` Juan Manuel Macías
2021-08-13 16:32   ` Roger Mason
2021-08-13 17:12     ` Juan Manuel Macías
2021-08-14 10:30       ` Roger Mason
2021-08-14 12:10 ` Maxim Nikulin [this message]
2021-08-17 20:42   ` Roger Mason

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='sf8br8$90c$1@ciao.gmane.io' \
    --to=manikulin@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).