From mboxrd@z Thu Jan 1 00:00:00 1970 From: emanuel.charpentier@gmail.com Subject: join two or more tables Date: Fri, 23 Aug 2019 11:55:23 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:56404) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i16I6-0005CE-II for emacs-orgmode@gnu.org; Fri, 23 Aug 2019 05:55:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i16I5-0001Ej-JL for emacs-orgmode@gnu.org; Fri, 23 Aug 2019 05:55:30 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:51950) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i16I5-0001B2-Cu for emacs-orgmode@gnu.org; Fri, 23 Aug 2019 05:55:29 -0400 Received: by mail-wm1-x341.google.com with SMTP id k1so8357746wmi.1 for ; Fri, 23 Aug 2019 02:55:28 -0700 (PDT) In-Reply-To: 871rxirifk.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: oub@mat.ucm.es Cc: emacs-orgmode > Hi > > I was googling this a bit, I found more complicated scenarios, but > not how to join one or more tables. > > For example > #+begin_src > > #+tblname: nut > | type | Fiber | Sugar | Protein | Carb | > |----------+-------+-------+---------+------| > | eggplant | 2.5 | 3.2 | 0.8 | 8.6 | > | tomatoe | 0.6 | 2.1 | 0.8 | 3.4 | > | onion | 1.3 | 4.4 | 1.3 | 9.0 | > | egg | 0 | 18.3 | 31.9 | 18.3 | > > > #+tblname: nut2 > | type | Fiber | Sugar | Protein | Carb | > |----------+-------+-------+---------+------| > | rice | 0.2 | 0 | 1.5 | 16.0 | > | bread | 0.7 | 0.7 | 3.3 | 16.0 | > | orange | 3.1 | 11.9 | 1.3 | 17.6 | > | banana | 2.1 | 9.9 | 0.9 | 18.5 | > | tofu | 0.7 | 0.5 | 6.6 | 1.4 | > | nut | 2.6 | 1.3 | 4.9 | 7.2 | > | corn | 4.7 | 1.8 | 2.8 | 21.3 | > #+end_src What about: #+begin_src emacs-lisp :var t1=nut :var t2=nut2 :colnames yes (append t1 t2) #+end_src #+RESULTS: | type | Fiber | Sugar | Protein | Carb | |----------+-------+-------+---------+------| | eggplant | 2.5 | 3.2 | 0.8 | 8.6 | | tomatoe | 0.6 | 2.1 | 0.8 | 3.4 | | onion | 1.3 | 4.4 | 1.3 | 9.0 | | egg | 0 | 18.3 | 31.9 | 18.3 | | rice | 0.2 | 0 | 1.5 | 16.0 | | bread | 0.7 | 0.7 | 3.3 | 16.0 | | orange | 3.1 | 11.9 | 1.3 | 17.6 | | banana | 2.1 | 9.9 | 0.9 | 18.5 | | tofu | 0.7 | 0.5 | 6.6 | 1.4 | | nut | 2.6 | 1.3 | 4.9 | 7.2 | | corn | 4.7 | 1.8 | 2.8 | 21.3 | Of course, this works because both tables have headers, which can be handled by the ":colnames yes" header-argument. If both are headerless, "colnames: no" would do the trick. Handling the case where one has headers and the other not, or when there are hlines in the table is still a conudrum for me: I haven't (yet) been able to find the documentation on how these things are stored... HTH, -- Emmanuel Charpentier