From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Banel Subject: Re: extract a column from a table but but an name on the new table Date: Sat, 26 May 2018 09:20:37 +0200 Message-ID: <5B090AC5.3060607@free.fr> References: <87y3g9fbfu.fsf@mat.ucm.es> Mime-Version: 1.0 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fMTVN-00042P-Hp for emacs-orgmode@gnu.org; Sat, 26 May 2018 03:20:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fMTVI-0002al-WD for emacs-orgmode@gnu.org; Sat, 26 May 2018 03:20:45 -0400 Received: from smtp3-g21.free.fr ([2a01:e0c:1:1599::12]:40681) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fMTVI-0002aP-QD for emacs-orgmode@gnu.org; Sat, 26 May 2018 03:20:40 -0400 Received: from [IPv6:2a01:e35:2e21:def0:35a9:b424:a5e1:fc69] (unknown [IPv6:2a01:e35:2e21:def0:35a9:b424:a5e1:fc69]) by smtp3-g21.free.fr (Postfix) with ESMTP id E8B9A13F88F for ; Sat, 26 May 2018 09:20:38 +0200 (CEST) In-Reply-To: <87y3g9fbfu.fsf@mat.ucm.es> 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" To: emacs-orgmode@gnu.org
On 24/05/2018 15:08, Uwe Brauer wrote:=
Hi

Thierry Banel one of the authors of orgtbl-aggregate.el

Suggested to me the following code, if just want to extract one column
of a table.


#+TBLNAME: raw-data
| 1 | a | 3 |
| 2 | b | 4 |
| 3 | c | 6 |
| 4 | d | 7 |

#+BEGIN_SRC elisp :var data=3Draw-data
(mapcar (lambda (line)
            (list (nth 2 line)))
         data)
#+END_SRC

#+RESULTS:
| 3 |
| 4 |
| 6 |
| 7 |

It works nicely but how could I obtain the result with a table name,
like:

#+TBLNAME: RESULTS
| 3 |
| 4 |
| 6 |
| 7 |

Or something like this?

Thanks

Uwe Brauer=20




You may name the Lisp block like that:

--------------------------------------

#+TBLNAME: raw-data
| 1 | a | 3 |
| 2 | b | 4 |
| 3 | c | 6 |
| 4 | d | 7 |

#+NAME: just-one-column
#+BEGIN_SRC elisp :var data=3Draw-data
(mapcar (lambda (line)
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (list (nth 2 line)))<= tt>
=A0=A0=A0=A0=A0=A0=A0=A0 data)
#+END_SRC

#+RESULTS: just-one-column
| 3 |
| 4 |
| 6 |
| 7 |

--------------------------------------


Then you can use the new table in a further processing:

--------------------------------------

#+BEGIN_SRC elisp :var data=3Djust-one-column
(mapcar (lambda (line)
=A0=A0=A0=A0=A0=A0=A0=A0=A0 (list (* 1000 (nth 0 line))))
=A0=A0=A0=A0=A0=A0=A0=A0 data)
#+END_SRC

#+RESULTS:
| 3000 |
| 4000 |
| 6000 |
| 7000 |

--------------------------------------