emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* evaluate TBLFM
@ 2015-06-11 19:45 Charles Millar
  2015-07-21 13:28 ` Grant Rettke
  2015-07-30 19:41 ` Charles Millar
  0 siblings, 2 replies; 4+ messages in thread
From: Charles Millar @ 2015-06-11 19:45 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

Hi,

I am learning how to use org-babel and want to export (LaTeX) a table 
with the final column added at final row, which should be inserted. The 
entire process would take place upon exporting to LaTeX/pdf

Desired result (roughly speaking)

| date | Description | Amount    |
|--------|----------------|---------------|
| 6-7   | blah            |     1.00      |
| 6-8   | blah blah    |    2.00       |
|         |                    |    3.00        | (this row to be 
inserted and then column 3 added) (Also nice if a hline were inserted 
before the last row)

The table is generated from a recutils data base and essentially this is 
the set up


#+Name: ATable
#+begin_src rec data: Foo.rec :type Bar :fields date,Description,Amount
#+end_src

#+TBLNAME: ATable
#+TBLFM: @>$>=vsum(@I$>..@>>$>);%.2f

I have read Using Code Blocks in Org Tables in the Worg Babel 
Introduction and searched the lists and am not sure of how to implement 
this.

At the moment I am more interested in solving the column sum problem; i 
can kludge an  added row using a dummy record in the database.

Charlie Millar

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: evaluate TBLFM
  2015-06-11 19:45 evaluate TBLFM Charles Millar
@ 2015-07-21 13:28 ` Grant Rettke
  2015-07-26 14:01   ` Charles Millar
  2015-07-30 19:41 ` Charles Millar
  1 sibling, 1 reply; 4+ messages in thread
From: Grant Rettke @ 2015-07-21 13:28 UTC (permalink / raw)
  To: Charles Millar; +Cc: emacs-orgmode@gnu.org

On Thu, Jun 11, 2015 at 2:45 PM, Charles Millar <millarc@verizon.net> wrote:
> I am learning how to use org-babel and want to export (LaTeX) a table with
> the final column added at final row, which should be inserted. The entire
> process would take place upon exporting to LaTeX/pdf
>
> Desired result (roughly speaking)
>
> | date | Description | Amount    |
> |--------|----------------|---------------|
> | 6-7   | blah            |     1.00      |
> | 6-8   | blah blah    |    2.00       |
> |         |                    |    3.00        | (this row to be inserted
> and then column 3 added) (Also nice if a hline were inserted before the last
> row)
>
> The table is generated from a recutils data base and essentially this is the
> set up
>
>
> #+Name: ATable
> #+begin_src rec data: Foo.rec :type Bar :fields date,Description,Amount
> #+end_src
>
> #+TBLNAME: ATable
> #+TBLFM: @>$>=vsum(@I$>..@>>$>);%.2f
>
> I have read Using Code Blocks in Org Tables in the Worg Babel Introduction
> and searched the lists and am not sure of how to implement this.

I'm not sure what you are trying to perform with this code. That
probably says more about me than you.

Are you loading the contents of a recfile into an Org-Mode table and
them performing a manipulation on that table? Is that what you want to
do? You said that you are not sure how to implement this and I am not
sure what precisely you want to implement.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: evaluate TBLFM
  2015-07-21 13:28 ` Grant Rettke
@ 2015-07-26 14:01   ` Charles Millar
  0 siblings, 0 replies; 4+ messages in thread
From: Charles Millar @ 2015-07-26 14:01 UTC (permalink / raw)
  To: emacs-orgmode@gnu.org

[-- Attachment #1: Type: text/plain, Size: 3225 bytes --]

Hi Grant,

On 07/21/2015 09:28 AM, Grant Rettke wrote:
> On Thu, Jun 11, 2015 at 2:45 PM, Charles Millar <millarc@verizon.net> wrote:
>> I am learning how to use org-babel and want to export (LaTeX) a table with
>> the final column added at final row, which should be inserted. The entire
>> process would take place upon exporting to LaTeX/pdf
>>
>> Desired result (roughly speaking)
>>
>> | date | Description | Amount    |
>> |--------|----------------|---------------|
>> | 6-7   | blah            |     1.00      |
>> | 6-8   | blah blah    |    2.00       |
>> |         |                    |    3.00        | (this row to be inserted
>> and then column 3 added) (Also nice if a hline were inserted before the last
>> row)
>>
>> The table is generated from a recutils data base and essentially this is the
>> set up
>>
>>
>> #+Name: ATable
>> #+begin_src rec data: Foo.rec :type Bar :fields date,Description,Amount
>> #+end_src
>>
>> #+TBLNAME: ATable
>> #+TBLFM: @>$>=vsum(@I$>..@>>$>);%.2f
>>
>> I have read Using Code Blocks in Org Tables in the Worg Babel Introduction
>> and searched the lists and am not sure of how to implement this.
> I'm not sure what you are trying to perform with this code. That
> probably says more about me than you.
>
> Are you loading the contents of a recfile into an Org-Mode table and
> them performing a manipulation on that table? Is that what you want to
> do? You said that you are not sure how to implement this and I am not
> sure what precisely you want to implement.
>
By the time I arrived at the end of my message the question was vague - 
very vague!

I have no trouble generating a table using the a src block from a 
recutils file
#+Name: ATable
#+begin_src rec data: Foo.rec :type Bar :fields date,Description,Amount
#+end_src
#+TBLNAME: ATable

results in

#+Name: ATable
#+begin_src rec data: Foo.rec :type Bar :fields date,Description,Amount
#+end_src
#+TBLNAME: ATable
| date   | Description | Amount |
|--------|-------------|--------|
| 6-7    | blah        |  1.00  |
| 6-8    | blah blah   |  2.00  |

Using code I would like to insert a row after the last row from the recutil file, put the word "Total" in  the last cell in the "Description" column and in the last cell in the Amount column total the cells above.

 From what I have read, I think source code at the beginning of the file would be possible and then that code would be called using the :post header command

the desired result is

#+Name: ATable
#+begin_src rec data: Foo.rec :type Bar :fields date,Description,Amount (possibly wiht :post *this*
#+end_src
#+TBLNAME: ATable
| date   | Description | Amount |
|--------|-------------|--------|
| 6-7    | blah        |  1.00  |
| 6-8    | blah blah   |  2.00  |
|	 | Total       |  3.00  |


I want to avoid using the keyboard to modify the table, i.e. go to last row, M-S-<down> to add a row, go to "Description" column last cell and insert Total and then evaluate a
	#+TBLFM: @>$>=vsum(@I$>..@>>$>);%.2f
(Eventually there may be as many as twenty different tables; the above is the most simple type.)

My knowledge of emacs lisp is only enough to try to figure it out when I see the code; all other languages forget about it.

Charlie Millar


[-- Attachment #2: Type: text/html, Size: 3949 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: evaluate TBLFM
  2015-06-11 19:45 evaluate TBLFM Charles Millar
  2015-07-21 13:28 ` Grant Rettke
@ 2015-07-30 19:41 ` Charles Millar
  1 sibling, 0 replies; 4+ messages in thread
From: Charles Millar @ 2015-07-30 19:41 UTC (permalink / raw)
  To: emacs-orgmode

FWIW, the code in Miguel Ruiz's post earlier today

"TBLFM added to updated table as result of a emacs-lisp src block"

has pretty much answered my questions. Thank you, Miguel.

I'm not sure if it the most efficient or even elegant but here is what I 
came up with, so please comment and correct if there is a better way

#+Name: ATableP
#+begin_src rec data: Foo.rec :type Bar :fields date,Description,Amount 
:results silent
#+end_src
#+TBLNAME: ATable
src emacs-lisp :var table=ATableP :exports results
   (setq table (cons 'hline table))
   (setq table (cons '("Date" "Description" "Inventory") table))
   (setq table (append table '(("|Total"))))
   (setq table (append table '(("\n#+TBLFM: 
@>$>=vsum(@I$>..@>>$>);%.2f::"))))
   table
#+end_src
#+ATTR_LATEX: :environment longtable :align p{60pt}p{280pt}N{8}{2}
#+TBLNAME: SCHEDA
| date | Description | Amount    | (resulting table, after C-c C-v s)
|--------|----------------|---------------|
| 6-7   | blah            |     1.00      |
| 6-8   | blah blah    |    2.00       |
|         | Total           |    3.00        |


On 06/11/2015 03:45 PM, Charles Millar wrote:
> Hi,
>
> I am learning how to use org-babel and want to export (LaTeX) a table 
> with the final column added at final row, which should be inserted. 
> The entire process would take place upon exporting to LaTeX/pdf
>
> Desired result (roughly speaking)
>
> | date | Description | Amount    |
> |--------|----------------|---------------|
> | 6-7   | blah            |     1.00      |
> | 6-8   | blah blah    |    2.00       |
> |         |                    |    3.00        | (this row to be 
> inserted and then column 3 added) (Also nice if a hline were inserted 
> before the last row)
>
> The table is generated from a recutils data base and essentially this 
> is the set up
>
>
> #+Name: ATable
> #+begin_src rec data: Foo.rec :type Bar :fields date,Description,Amount
> #+end_src
>
> #+TBLNAME: ATable
> #+TBLFM: @>$>=vsum(@I$>..@>>$>);%.2f
>
> I have read Using Code Blocks in Org Tables in the Worg Babel 
> Introduction and searched the lists and am not sure of how to 
> implement this.
>
> At the moment I am more interested in solving the column sum problem; 
> i can kludge an  added row using a dummy record in the database.
>
> Charlie Millar
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-07-30 19:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-11 19:45 evaluate TBLFM Charles Millar
2015-07-21 13:28 ` Grant Rettke
2015-07-26 14:01   ` Charles Millar
2015-07-30 19:41 ` Charles Millar

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).