emacs-orgmode
[Top][All Lists]
Advanced

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

[O] combining a source code block and TBLFM


From: Brad Knotwell
Subject: [O] combining a source code block and TBLFM
Date: Mon, 25 Jun 2018 16:41:29 +0000 (UTC)

Good day all--

Beyond outputting raw orgmode text, is there a way to do the following:

* take the table output of a source block
* apply a TBLFM operation on it

I have a contrived example below:

#+name: x
| a | 3 | 4 |  5 |
| b | 6 | 8 | 10 |

#+begin_src python :var x=x :results value table
x[0].append('')
x[1].append('')
x.insert(0,['Item','x','y','z','Total'])
x.insert(1,None)
x.append(None)
x.append(['Total','','','',''])
x.append(None)
x.insert(0,None)
return x
#+end_src

#+RESULTS:
|-------+---+---+----+-------|
| Item  | x | y |  z | Total |
|-------+---+---+----+-------|
| a     | 3 | 4 |  5 |       |
| b     | 6 | 8 | 10 |       |
|-------+---+---+----+-------|
| Total |   |   |    |       |
|-------+---+---+----+-------|

I would like the following formula to be applied:

#+TBLFM: @>$2=vsum(@address@hidden)::@>$3=vsum(@address@hidden)::@>$4=vsum(@address@hidden)::$5=$2+$3+$4

but I can't figure out how to keep the evaluation from overwriting the #+TBLFM: line.  While I realize I could just sum everything up in the python code (preferred) or return raw org-mode data (ugly), it occurred to me that there might be an elegant way to do this.

Thx.

--Brad



Thx.

--Brad

reply via email to

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