From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Brand Subject: Re: Computing the value of some cells of a table using a named code block Date: Wed, 2 Apr 2014 14:33:54 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVKMd-0003oK-Uh for emacs-orgmode@gnu.org; Wed, 02 Apr 2014 08:33:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WVKMc-0007P5-V0 for emacs-orgmode@gnu.org; Wed, 02 Apr 2014 08:33:55 -0400 Received: from mail-qg0-x232.google.com ([2607:f8b0:400d:c04::232]:57920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WVKMc-0007Ou-R5 for emacs-orgmode@gnu.org; Wed, 02 Apr 2014 08:33:54 -0400 Received: by mail-qg0-f50.google.com with SMTP id q108so113174qgd.9 for ; Wed, 02 Apr 2014 05:33:54 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Alan Schmitt Cc: emacs-orgmode Hi Alan On Wed, Apr 2, 2014 at 1:58 PM, Alan Schmitt wrote: > I have a table that summarizes my monthly budget, and I would like to > add a column where I compute my actual spending. I can get this > information using a shell script, but I don't know how to integrate it > in the table. > > Here is a contrived example: > --8<---------------cut here---------------start------------->8--- > #+name: spending > #+begin_src sh :var category="foo" > echo $category > #+end_src > > | Category | Budget | Spending | > |----------+--------+----------| > | Food | 1000 | | > | Rent | 1000 | | > #+TBLFM: $3=call_spending("$1") > --8<---------------cut here---------------end--------------->8--- > > My question is: how do I write the TBLFM so that every cell of column > 3 is the result of call the named block with column 1 as argument? When there is no named source block involved I use just | Category | Budget | Spending | |----------+--------+----------| | Food | 1000 | Food | | Rent | 1000 | Rent | #+TBLFM: $3 = '(org-trim (shell-command-to-string (concat "echo " $1))) For named source blocks there is sbe, see Worg. Michael