emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] sum up variables from different org-mode tables


From: Eric Schulte
Subject: Re: [O] sum up variables from different org-mode tables
Date: Mon, 19 Nov 2012 14:21:32 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Martin Gross <address@hidden> writes:

> Dear Michael,
>
> thank you very much, this is what I was looking for.  I myself
> supposed the answer should be related to "remote references", but was
> not sure how to use them.
>
> Just one point is not yet optimum to me: I do not have just 2 tables,
> but hundreds.  It would be hard and not very clean to add them all one
> by one.  Do you know if it there is a better way to reference remote
> tables?

Not a pure Org-mode solution, but something like the attached could be
used to sum up a particular column from every table in a file.  Not
flexible but possibly sufficient.

#+Title: Example 

* one table
| 1 |  2 |
| 2 |  4 |
| 3 |  6 |
| 4 |  8 |
| 5 | 10 |

* another table
| 20 | 20 |

* and one more
| 0 | 1 |
| 0 | 1 |

* here we sum them up
#+begin_src sh :results scalar :var file=(buffer-file-name) :var col=1
  cat $file|grep "^|"|sed 's/|//g'|awk '{ sum += $1} END{ print sum }'
#+end_src

#+RESULTS:
: 35
> For example telling org-mode to search data from all tables but "this"
> one?
>

With a little more work and one more sed command this could stop
processing the file at a particular line or keyword.

Hope this helps,

>
> Best regards,
>
> Martin
>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

reply via email to

[Prev in Thread] Current Thread [Next in Thread]