emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Advanced table
@ 2009-09-26 13:20 andrea Crotti
  2009-09-29 19:15 ` Eric Schulte
  0 siblings, 1 reply; 2+ messages in thread
From: andrea Crotti @ 2009-09-26 13:20 UTC (permalink / raw)
  To: emacs-orgmode

   I was trying to write down everything I spend and where I do, so I set up this simple table.
   So basically every day I have some expenses and on top I have the total.
   
   If the pattern is always the same (vsum(@+I..@+II)) I would like to have that formula every time I add a 
new thing.
   
   Now supposing that I always write the same day I pay best thing would be to have an automatic system 
that asks me the various fields and insert them in the table, does it make sense?
   
   
   | DATA             | WHAT       | WHERE       | HOW MUCH |
   |------------------+------------+-------------+----------|
   | [2009-09-25 Fri] |            |             |    28.95 |
   |------------------+------------+-------------+----------|
   |                  | food       | supermarket |     7.85 |
   |                  | ticket bus |             |      2.3 |
   |                  | tea + ice  | ice uno     |      4.4 |
   |                  | ticket     |             |     14.4 |
   |------------------+------------+-------------+----------|
   | [2009-09-26 Sat] |            |             |       41 |
   ...

   This was an example of the data. I'm not quite sure that this data structure would be later easy to 
manipulate, what do you think?
   Better solutions??

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

* Re: Advanced table
  2009-09-26 13:20 Advanced table andrea Crotti
@ 2009-09-29 19:15 ` Eric Schulte
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Schulte @ 2009-09-29 19:15 UTC (permalink / raw)
  To: andrea Crotti; +Cc: emacs-orgmode

Hi,

Using Org-babel the following source-code block could prove at least a
partial solution.

--8<---------------cut here---------------start------------->8---
#+begin_src emacs-lisp
  (let ((total 0) (responding t) purchases)
    (while responding
      (setq purchases
            (cons
             (list ""
                   (read-from-minibuffer "What: ")
                   (read-from-minibuffer "Where: ")
                   (read-minibuffer "How Much: "))
             purchases))
      (setq responding (y-or-n-p "more? ")))
    (append 
     purchases
     (list
      (list
       (format-time-string "%Y-%m-%d" (current-time))
       "" "" (progn
               (mapc (lambda (purchase)
                       (setq total (+ total (fourth purchase))))
                     purchases)
               total)))))
#+end_src
--8<---------------cut here---------------end--------------->8---

With Org-babel loaded, simply evaluate the block (press C-c C-c with the
cursor on/in the block) and the desired table portion will be placed
into your Org-mode file.  At the moment I can't recall how to remove the
quotes from the strings, but it should certainly be doable.

with slight modification it would also be possible to append the table
to an existing table, etc...

Best -- Eric

andrea Crotti <andrea.crotti.0@gmail.com> writes:

>    I was trying to write down everything I spend and where I do, so I set up this simple table.
>    So basically every day I have some expenses and on top I have the total.
>    
>    If the pattern is always the same (vsum(@+I..@+II)) I would like to have that formula every time I add a 
> new thing.
>    
>    Now supposing that I always write the same day I pay best thing would be to have an automatic system 
> that asks me the various fields and insert them in the table, does it make sense?
>    
>    
>    | DATA             | WHAT       | WHERE       | HOW MUCH |
>    |------------------+------------+-------------+----------|
>    | [2009-09-25 Fri] |            |             |    28.95 |
>    |------------------+------------+-------------+----------|
>    |                  | food       | supermarket |     7.85 |
>    |                  | ticket bus |             |      2.3 |
>    |                  | tea + ice  | ice uno     |      4.4 |
>    |                  | ticket     |             |     14.4 |
>    |------------------+------------+-------------+----------|
>    | [2009-09-26 Sat] |            |             |       41 |
>    ...
>
>    This was an example of the data. I'm not quite sure that this data structure would be later easy to 
> manipulate, what do you think?
>    Better solutions??
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

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

end of thread, other threads:[~2009-09-29 19:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-26 13:20 Advanced table andrea Crotti
2009-09-29 19:15 ` Eric Schulte

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).