From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id MCEBFzR8MWBqUQAA0tVLHw (envelope-from ) for ; Sat, 20 Feb 2021 21:16:36 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id wCrVEjR8MWDEEgAA1q6Kng (envelope-from ) for ; Sat, 20 Feb 2021 21:16:36 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E726921C9E for ; Sat, 20 Feb 2021 22:16:34 +0100 (CET) Received: from localhost ([::1]:59514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lDZc9-0005dT-Fl for larch@yhetil.org; Sat, 20 Feb 2021 16:16:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38972) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lDZaw-0005bz-4n for emacs-orgmode@gnu.org; Sat, 20 Feb 2021 16:15:18 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]:33494) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lDZat-0006WR-O4 for emacs-orgmode@gnu.org; Sat, 20 Feb 2021 16:15:17 -0500 Received: by mail-wm1-x332.google.com with SMTP id i7so5797676wmb.0 for ; Sat, 20 Feb 2021 13:15:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=andrew-cmu-edu.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=CoNfdGiju22Dp7yzZclIKvSL5fN8PuzgvgcxsKrIlMQ=; b=z9Jx7xSvdgYtLQPoqH0OfVKYkzUS2QqPLKPAasqyotw2VBMexy35Drq9jlP/RBe2Bj K1NXZz5GftP++Kv3buE3RXdqxNnE+C1Uax7H0o1ccst1jx9ikvdYx2X8OSgwPKrSCThm TrANwHcMhb86H/IMPLr53mY0baLApNxnldMF5nAf8fnmYpRrgyq6wsqKIl9+Lnbg5SSt m9OO7qLq9108+cfvxlBa7ikAg0GKhgKhJwhRYfYZ8HwHpuaiA/wSJ3FUcBc2Vs803lxi J3RZ2XZbkEwCxFIM1aUyBvwwbe0as/DVuPdyNDcmGjBnA3lrSyfkKvOFgEZIZHegX53k XUAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=CoNfdGiju22Dp7yzZclIKvSL5fN8PuzgvgcxsKrIlMQ=; b=hwzjQfIikomMI+PkFUtKXLepjNtOv0BUmyNuRzCXuV23gzX9Sihxbu++lXXN7cpxgK r2W57/ZuO8uGW4aF7WBown6FNk+RZelrEBPsShVDHU8Rc2Q21Vy9KLBMD3q1KwIAx5sg QjMpzgfeR+qVqGZvzs8ov1Vilvf1YYVCXpYLH/vp80Y0DUt05yutZmKN7jmV7zQRAeCc 0raYCmoaGFO4NmQsj97YNeYPBuGdbeL8/rOQ/VoFNsfGPqqxNhLZg7aR/pydrQEc7VI7 0E3GJewtMxfbj/YdalFlDrKYCwjIRwag+qAdK0XmakoPWXmKa1Bs9bTLs1UVSXKubpXD IDvw== X-Gm-Message-State: AOAM532exhSUit63CcowXmujC+mcra/alII20PSC2pqqrSgNMETP6k1k pKHaRi92NJV4RnfaVB/uCU0jKJZG4KEeDWS7SfS9TTn4854ESA== X-Google-Smtp-Source: ABdhPJypF2vy+9isZYRpdJVAQVCAldOy5h2cLDtDGc73TyK05wSK2wC7oSqgi2EiGoW6Vp00IrguEyFdHEkDKhPjDa8= X-Received: by 2002:a05:600c:3589:: with SMTP id p9mr13658333wmq.18.1613855713547; Sat, 20 Feb 2021 13:15:13 -0800 (PST) MIME-Version: 1.0 From: John Kitchin Date: Sat, 20 Feb 2021 16:15:02 -0500 Message-ID: Subject: state of the art in org-mode tables e.g. join, etc To: org-mode-email Content-Type: multipart/alternative; boundary="000000000000865dd305bbcb102e" Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=johnrkitchin@gmail.com; helo=mail-wm1-x332.google.com X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -0.97 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=andrew-cmu-edu.20150623.gappssmtp.com header.s=20150623 header.b=z9Jx7xSv; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=andrew.cmu.edu (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: E726921C9E X-Spam-Score: -0.97 X-Migadu-Scanner: scn0.migadu.com X-TUID: w9Ou4YFhiVhB --000000000000865dd305bbcb102e Content-Type: text/plain; charset="UTF-8" Is there a state of the art in using org-tables as little databases with joins and stuff? This package https://github.com/tbanel/orgtbljoin seems close, but not quite what I had in mind. I don't want to modify tables in place, or create dynamic tables. I do want to combine tables in memory though for subsequent calculations. I was thinking more like given the tables from that page: #+name: quantities | type-1 | quty | |----------+------| | onion | 70 | | tomatoe | 120 | | eggplant | 300 | | tofu | 100 | #+name: nutrition | type-2 | 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 | you would be able to do something like this: #+BEGIN_SRC emacs-lisp (join "quantities" "type-1" "nutrition" "type-2") #+END_SRC #+RESULTS: | type-1 | quty | Fiber | Sugar | Protein | Carb | |----------+------+-------+-------+---------+------| | onion | 70 | 1.3 | 4.4 | 1.3 | 9.0 | | tomatoe | 120 | 0.6 | 2.1 | 0.8 | 3.4 | | eggplant | 300 | 2.5 | 3.2 | 0.8 | 8.6 | | tofu | 100 | 0.7 | 0.5 | 6.6 | 1.4 | or, to sum the Fiber column: #+BEGIN_SRC emacs-lisp :var data=(join "quantities" "type-1" "nutrition" "type-2") (cl-loop for row in data sum (nth 2 row))) #+END_SRC #+RESULTS: : 5.1000000000000005 I have spent a lot of time with Pandas in Python lately, and trying to think through what some analogues with org-tables would be. I would be very happy not to reinvent the wheel here! John ----------------------------------- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu --000000000000865dd305bbcb102e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Is there a state of the art in using org-tables as little = databases with joins and stuff?


seems close, but not quite what I had=C2=A0in = mind. I don't want to modify tables in place, or create dynamic tables.= I do want to combine tables in memory though for subsequent calculations.<= /div>

I was thinking more like given the tables from tha= t page:

#+name: quantities
| type-1 =C2=A0 | qu= ty |
|----------+------|
| onion =C2=A0 =C2=A0| =C2=A0 70 |
| toma= toe =C2=A0| =C2=A0120 |
| eggplant | =C2=A0300 |
| tofu =C2=A0 =C2=A0= | =C2=A0100 |

#+name: nutrition
| type-2 =C2=A0 | Fiber | Sugar = | Protein | Carb |
|----------+-------+-------+---------+------|
| eg= gplant | =C2=A0 2.5 | =C2=A0 3.2 | =C2=A0 =C2=A0 0.8 | =C2=A08.6 |
| tom= atoe =C2=A0| =C2=A0 0.6 | =C2=A0 2.1 | =C2=A0 =C2=A0 0.8 | =C2=A03.4 |
|= onion =C2=A0 =C2=A0| =C2=A0 1.3 | =C2=A0 4.4 | =C2=A0 =C2=A0 1.3 | =C2=A09= .0 |
| egg =C2=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A0 0 | =C2=A018.3 | =C2=A0 = =C2=A031.9 | 18.3 |
| rice =C2=A0 =C2=A0 | =C2=A0 0.2 | =C2=A0 =C2=A0 0 = | =C2=A0 =C2=A0 1.5 | 16.0 |
| bread =C2=A0 =C2=A0| =C2=A0 0.7 | =C2=A0 = 0.7 | =C2=A0 =C2=A0 3.3 | 16.0 |
| orange =C2=A0 | =C2=A0 3.1 | =C2=A011= .9 | =C2=A0 =C2=A0 1.3 | 17.6 |
| banana =C2=A0 | =C2=A0 2.1 | =C2=A0 9.= 9 | =C2=A0 =C2=A0 0.9 | 18.5 |
| tofu =C2=A0 =C2=A0 | =C2=A0 0.7 | =C2= =A0 0.5 | =C2=A0 =C2=A0 6.6 | =C2=A01.4 |
| nut =C2=A0 =C2=A0 =C2=A0| = =C2=A0 2.6 | =C2=A0 1.3 | =C2=A0 =C2=A0 4.9 | =C2=A07.2 |
| corn =C2=A0 = =C2=A0 | =C2=A0 4.7 | =C2=A0 1.8 | =C2=A0 =C2=A0 2.8 | 21.3 |



#+BEGIN_SRC emacs-lisp :va= r data=3D(join "quantities" "type-1" "nutrition&qu= ot; "type-2")
(cl-loop for row in data sum (nth 2 row)))
#+= END_SRC

#+RESULTS:
: 5.1000000000000005

I = have spent a lot of time with Pandas in Python lately,=C2=A0 and trying to = think through what some analogues with org-tables would be. I would be very= happy not to reinvent the wheel here!


<= div>
--000000000000865dd305bbcb102e--