* How to retrieve ALL the information of an Org table ?
@ 2021-10-09 20:36 Emmanuel Charpentier
2021-10-10 1:03 ` Ihor Radchenko
0 siblings, 1 reply; 2+ messages in thread
From: Emmanuel Charpentier @ 2021-10-09 20:36 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 1868 bytes --]
Dear list,
I have problems with exploiting programatically the structure of an Org
table :
I want to write function acting on complex tables, where the original
information is presented along various statistics. My idea is to
isolate the original information in a range delimited (by convention)
by the first and second hlines and by the first and last columns ; the
function should accept the whole table and retrieve the original
data. The point is that the function should accept a variable number of
lines in both the "original data" range and the summary information.
Let ttest such a table with hlines :
#+name: ttest
| ttest | c1 | c2 | rSum |
|-------+----+----+------|
| 3 | 3 | 5 | 8 |
| 8 | 8 | 12 | 20 |
|-------+----+----+------|
| cSum | 11 | 17 | 28 |
#+TBLFM: @>$2..@>$>=vsum(@I..@II)::@2..@>>$4=vsum($<<..$>>)
ttestc1c2rSum3358881220cSum111728
Passing this table as an argument to source code loses the hlines :
#+begin_src emacs-lisp :exports results :results drawer :var foo=ttest
foo
#+end_src
((ttest c1 c2 rSum) (3 3 5 8) (8 8 12 20) (cSum 11 17 28))
The structure allowing to retrieve the original data is lost.
The point is that the source code can't exploit the hlines to find
relevant information (in the present case, the lines between the
hlines).
Alternatively, one may try and pass the relevant range, using foo=(org-
table-get-remote-range "ttest" "@I$<<..@II$>>") as an argument. This
fails for a different reason :
#+begin_src emacs-lisp :exports results :results drawer :var foo=(org-
table-get-remote-range "ttest" "@I$<<..@II$>>")
foo
#+end_src
(3 5 8 12)
Again, the structure is lost : this time, foo is a "flattened" vector,
whose matricial shape is lost to the processing function.
I am looking for explanations and/or hints.
Attached : the source of the present mail.
Thanks in advance...
--
Emmanuel Charpentier
[-- Attachment #1.2: Type: text/html, Size: 8811 bytes --]
[-- Attachment #2: TstTableRange.org --]
[-- Type: text/plain, Size: 2782 bytes --]
#+options: author:nil toc:nil
#+property: header-args:python :session
# #+latex_header: \usepackage{minted}
#+begin_src emacs-lisp :exports none
(setq org-odt-preferred-output-format "docx"
org-latex-to-mathml-convert-command
"latexmlmath \"%i\" --presentationmathml=%o"
;; org-latex-listings 'minted
org-latex-listings nil
org-latex-pdf-process
(list "latexmk -pdf -pdflatex='%latex -interaction=nonstopmode -shell-escape' -bibtex -f %f"))
#+end_src
#+RESULTS:
| latexmk -pdf -pdflatex='%latex -interaction=nonstopmode -shell-escape' -bibtex -f %f |
Dear list,
I have problems with exploiting /programatically/ the structure of an Org table :
I want to write function acting on complex tables, where the original information is presented along various statistics. My idea is to isolate the original information in a range delimited (by convention) by the first and second hlines and by the first and last columns ; the function should accept the whole table and retrieve the original data. /The point is that the function should accept a variable number of lines in both the "original data" range and the summary information./
Let =ttest= such a table with =hlines= :
#+begin_src org :eval yes :exports both :results replace
,#+name: ttest
| ttest | c1 | c2 | rSum |
|-------+----+----+------|
| 3 | 3 | 5 | 8 |
| 8 | 8 | 12 | 20 |
|-------+----+----+------|
| cSum | 11 | 17 | 28 |
,#+TBLFM: @>$2..@>$>=vsum(@I..@II)::@2..@>>$4=vsum($<<..$>>)
#+end_src
#+RESULTS:
#+name: ttest
| ttest | c1 | c2 | rSum |
|-------+----+----+------|
| 3 | 3 | 5 | 8 |
| 8 | 8 | 12 | 20 |
|-------+----+----+------|
| cSum | 11 | 17 | 28 |
#+TBLFM: @>$2..@>$>=vsum(@I..@II)::@2..@>>$4=vsum($<<..$>>)
Passing this table as an argument to source code loses the hlines :
#+begin_src org :eval yes :exports both :results replace
,#+begin_src emacs-lisp :exports results :results drawer :var foo=ttest
foo
,#+end_src
#+end_src
The structure allowing to retrieve the original data is lost.
The point is that the source code can't exploit the hlines to find relevant information (in the present case, the lines between the hlines).
Alternatively, one may try and pass the relevant range, using =foo=(org-table-get-remote-range "ttest" "@I$<<..@II$>>")= as an argument. This fails for a different reason :
#+begin_src org :eval yes :exports both :results replace
,#+begin_src emacs-lisp :exports results :results drawer :var foo=(org-table-get-remote-range "ttest" "@I$<<..@II$>>")
foo
,#+end_src
#+end_src
Again, the structure is lost : this time, =foo= is a "flattened" vector, whose matricial shape is lost to the processing function.
I am looking for explanations and/or hints.
# Local Variables:
# org-latex_listings: nil
# End:
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: How to retrieve ALL the information of an Org table ?
2021-10-09 20:36 How to retrieve ALL the information of an Org table ? Emmanuel Charpentier
@ 2021-10-10 1:03 ` Ihor Radchenko
0 siblings, 0 replies; 2+ messages in thread
From: Ihor Radchenko @ 2021-10-10 1:03 UTC (permalink / raw)
To: Emmanuel Charpentier; +Cc: emacs-orgmode
Emmanuel Charpentier <emm.charpentier@free.fr> writes:
> Passing this table as an argument to source code loses the hlines :
> #+begin_src emacs-lisp :exports results :results drawer :var foo=ttest
> foo
> #+end_src
I think you are looking for ":hlines yes" header arg (the default is no)
Best,
Ihor
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-10 1:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-09 20:36 How to retrieve ALL the information of an Org table ? Emmanuel Charpentier
2021-10-10 1:03 ` Ihor Radchenko
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.