* Include results in a table
@ 2014-10-28 9:02 abonnements
2014-10-28 9:34 ` Thorsten Jolitz
2014-10-28 10:54 ` Michael Brand
0 siblings, 2 replies; 5+ messages in thread
From: abonnements @ 2014-10-28 9:02 UTC (permalink / raw)
To: emacs-orgmode
Hello everybody,
I have somethink like that
#+call: gen(A)
#+results: A
: 10
#+call: gen(B)
#+results: B
: 20
Is there a simple mean to aggregate the results in a table, i.e to get
| A | 10 |
| B | 20 |
I think some lisp can do that but as a beginner... but as I want to
learn you can suggest a somewhat complicated solution or a simple idea.
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Include results in a table
2014-10-28 9:02 abonnements
@ 2014-10-28 9:34 ` Thorsten Jolitz
2014-10-28 10:54 ` Michael Brand
1 sibling, 0 replies; 5+ messages in thread
From: Thorsten Jolitz @ 2014-10-28 9:34 UTC (permalink / raw)
To: emacs-orgmode
abonnements <abonnements@thierry-pelle.eu> writes:
Hello,
> I have somethink like that
>
> #+call: gen(A)
> #+results: A
> : 10
>
> #+call: gen(B)
> #+results: B
> : 20
>
> Is there a simple mean to aggregate the results in a table, i.e to get
> | A | 10 |
> | B | 20 |
>
> I think some lisp can do that but as a beginner... but as I want to
> learn you can suggest a somewhat complicated solution or a simple idea.
> Thanks.
you could define a 3rd block C that takes the results from block A and B
as variable via :vars x=A y=B (A and B must be named blocks for this,
use a #+NAME: A line) and then do (list A x B y) in block C and use the
:results format that outputs a list as a table (often it is the default,
otherwise try :results table or so).
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Include results in a table
@ 2014-10-28 10:08 abonnements
2014-10-28 10:44 ` Thorsten Jolitz
0 siblings, 1 reply; 5+ messages in thread
From: abonnements @ 2014-10-28 10:08 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1040 bytes --]
Hi, thank you for your answer.
Your solution is OK but only for the example I gave (2 or 3 results). In practice I have about 10 results and the number of them may be variable...
Furthermore :vars does not work on my version (I must use :var x=A :var y=B)...
Ta.
Thierry
Hello,
>/ I have somethink like that/
>
>/ #+call: gen(A)/
>/ #+results: A/
>/ : 10/
>
>/ #+call: gen(B)/
>/ #+results: B/
>/ : 20/
>
>/ Is there a simple mean to aggregate the results in a table, i.e to get/
>/ | A | 10 |/
>/ | B | 20 |/
>
>/ I think some lisp can do that but as a beginner... but as I want to/
>/ learn you can suggest a somewhat complicated solution or a simple idea./
>/ Thanks./
you could define a 3rd block C that takes the results from block A and B
as variable via :vars x=A y=B (A and B must be named blocks for this,
use a #+NAME: A line) and then do (list A x B y) in block C and use the
:results format that outputs a list as a table (often it is the default,
otherwise try :results table or so).
--
cheers,
Thorsten
[-- Attachment #2: Type: text/html, Size: 1329 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Include results in a table
2014-10-28 10:08 Include results in a table abonnements
@ 2014-10-28 10:44 ` Thorsten Jolitz
0 siblings, 0 replies; 5+ messages in thread
From: Thorsten Jolitz @ 2014-10-28 10:44 UTC (permalink / raw)
To: emacs-orgmode
abonnements <abonnements@thierry-pelle.eu> writes:
> Hi, thank you for your answer.
>
> Your solution is OK but only for the example I gave (2 or 3
> results). In practice I have about 10 results and the number of them
> may be variable... Furthermore :vars does not work on my version (I
> must use :var x=A :var y=B)...
:vars was just a typo then ....
#+NAME: A
#+BEGIN_SRC emacs-lisp :results raw
(+ 2 2)
#+END_SRC
#+results: A
4
#+NAME: B
#+BEGIN_SRC emacs-lisp :results raw
(/ 2 2)
#+END_SRC
#+results: B
1
#+BEGIN_SRC emacs-lisp
(org-element-map (org-element-parse-buffer) 'src-block
(lambda (--block)
(let ((nm (org-element-property :name --block)))
(when nm
(let ((val (org-element-property :value --block)))
(list nm (eval (car (read-from-string val)))))))))
#+END_SRC
#+results:
| A | 4 |
| B | 1 |
> Ta.
> Thierry
>
> Hello,
>
>> I have somethink like that
>>
>> #+call: gen(A)
>> #+results: A
>> : 10
>>
>> #+call: gen(B)
>> #+results: B
>> : 20
>>
>> Is there a simple mean to aggregate the results in a table, i.e to get
>> | A | 10 |
>> | B | 20 |
>>
>> I think some lisp can do that but as a beginner... but as I want to
>> learn you can suggest a somewhat complicated solution or a simple idea.
>> Thanks.
>
> you could define a 3rd block C that takes the results from block A and B
> as variable via :vars x=A y=B (A and B must be named blocks for this,
> use a #+NAME: A line) and then do (list A x B y) in block C and use the
> :results format that outputs a list as a table (often it is the default,
> otherwise try :results table or so).
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Include results in a table
2014-10-28 9:02 abonnements
2014-10-28 9:34 ` Thorsten Jolitz
@ 2014-10-28 10:54 ` Michael Brand
1 sibling, 0 replies; 5+ messages in thread
From: Michael Brand @ 2014-10-28 10:54 UTC (permalink / raw)
To: abonnements; +Cc: Org Mode
Hi Thierry
On Tue, Oct 28, 2014 at 10:02 AM, abonnements
<abonnements@thierry-pelle.eu> wrote:
> #+call: gen(A)
> #+results: A
> : 10
>
> #+call: gen(B)
> #+results: B
> : 20
>
> Is there a simple mean to aggregate the results in a table, i.e to get
> | A | 10 |
> | B | 20 |
One solution with TBLFM is:
#+BEGIN_SRC emacs-lisp
'(10)
#+END_SRC
#+NAME: A
#+RESULTS:
| 10 |
#+BEGIN_SRC emacs-lisp
'(20)
#+END_SRC
#+NAME: B
#+RESULTS:
| 20 |
Aggregate multiple tables:
| Table | Value |
|-------+-------|
| A | 10 |
| B | 20 |
#+TBLFM: @<<$2..@>$2 = remote($1, @1$1)
Requires Emacs 24.4 or an Org version from at least 2014.
For reference see also the unit test in the Org source
testing/lisp/test-org-table.el test-org-table/remote-reference-indirect
Michael
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-10-28 10:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-28 10:08 Include results in a table abonnements
2014-10-28 10:44 ` Thorsten Jolitz
-- strict thread matches above, loose matches on Subject: below --
2014-10-28 9:02 abonnements
2014-10-28 9:34 ` Thorsten Jolitz
2014-10-28 10:54 ` Michael Brand
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.