emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* join two or more tables
@ 2019-08-18  8:23 Uwe Brauer
  2019-08-18  8:31 ` Uwe Brauer
  2019-08-18 10:21 ` Ken Mankoff
  0 siblings, 2 replies; 12+ messages in thread
From: Uwe Brauer @ 2019-08-18  8:23 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1027 bytes --]


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


I want to generate a new table total-nuts, which is just a combination
of the two tables, nuts and nuts2 


Uwe Brauer 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5025 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread
* join two or more tables
@ 2019-08-23  9:55 emanuel.charpentier
  2019-08-23 10:54 ` Uwe Brauer
  0 siblings, 1 reply; 12+ messages in thread
From: emanuel.charpentier @ 2019-08-23  9:55 UTC (permalink / raw)
  To: oub; +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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-08-23 18:10 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-18  8:23 join two or more tables Uwe Brauer
2019-08-18  8:31 ` Uwe Brauer
2019-08-18  8:46   ` [SOLVED] (was: join two or more tables) Uwe Brauer
2019-08-18  8:59     ` [rows not columns] (was: [SOLVED]) Uwe Brauer
2019-08-18 11:00   ` join two or more tables Jude DaShiell
2019-08-18 10:21 ` Ken Mankoff
2019-08-18 10:24   ` Uwe Brauer
2019-08-18 10:49     ` Achim Gratz
2019-08-18 11:34       ` Uwe Brauer
2019-08-23 18:09         ` Achim Gratz
  -- strict thread matches above, loose matches on Subject: below --
2019-08-23  9:55 emanuel.charpentier
2019-08-23 10:54 ` Uwe Brauer

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).