emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-table Row Count Formula
@ 2014-07-30  8:30 Esben Stien
  2014-07-30  8:52 ` Eric Abrahamsen
  2014-07-30  8:57 ` Thorsten Jolitz
  0 siblings, 2 replies; 4+ messages in thread
From: Esben Stien @ 2014-07-30  8:30 UTC (permalink / raw)
  To: emacs-orgmode

I'm trying to figure out how to get the number of rows in an org-table,
but I can't find this in the documentation. 

Anyone have an idea?

-- 
Esben Stien is b0ef@e     s      a             
         http://www. s     t    n m
          irc://irc.  b  -  i  .   e/%23contact
           sip:b0ef@   e     e 
           jid:b0ef@    n     n

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

* Re: org-table Row Count Formula
  2014-07-30  8:30 org-table Row Count Formula Esben Stien
@ 2014-07-30  8:52 ` Eric Abrahamsen
  2014-08-01 21:22   ` Michael Brand
  2014-07-30  8:57 ` Thorsten Jolitz
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Abrahamsen @ 2014-07-30  8:52 UTC (permalink / raw)
  To: emacs-orgmode

Esben Stien <b0ef@esben-stien.name> writes:

> I'm trying to figure out how to get the number of rows in an org-table,
> but I can't find this in the documentation. 
>
> Anyone have an idea?

The vcount function will count the number of elements in a vector, so
you could probably pass a range reference, like @1..@> (first row to
last row) to vcount. I think empty rows would be omitted, though.

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

* Re: org-table Row Count Formula
  2014-07-30  8:30 org-table Row Count Formula Esben Stien
  2014-07-30  8:52 ` Eric Abrahamsen
@ 2014-07-30  8:57 ` Thorsten Jolitz
  1 sibling, 0 replies; 4+ messages in thread
From: Thorsten Jolitz @ 2014-07-30  8:57 UTC (permalink / raw)
  To: emacs-orgmode

Esben Stien <b0ef@esben-stien.name> writes:

> I'm trying to figure out how to get the number of rows in an org-table,
> but I can't find this in the documentation. 
>
> Anyone have an idea?

As always, there might be some Org function for this, but otherwise here
is a starting point:

#+begin_src emacs-lisp
  (defun tj/count-tbl-rows (&optional tbl-as-lisp)
    "Return number of tbl rows for tbl at point."
    (interactive)
    (let ((rows (if tbl-as-lisp
                    (length tbl-as-lisp)
                  (length (org-table-to-lisp)))))
      (message "Table has %d Rows" rows)
      rows))
#+end_src

#+results:
: tj/count-tbl-rows

#+NAME: nice-tbl
| pretty | impressive | table |
| pretty | impressive | table |
| pretty | impressive | table |
| pretty | impressive | table |
| pretty | impressive | table |
| pretty | impressive | table |

#+header: :var data=nice-tbl
#+begin_src emacs-lisp 
(tj/count-tbl-rows data)
#+end_src

#+results:
: 6

-- 
cheers,
Thorsten

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

* Re: org-table Row Count Formula
  2014-07-30  8:52 ` Eric Abrahamsen
@ 2014-08-01 21:22   ` Michael Brand
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Brand @ 2014-08-01 21:22 UTC (permalink / raw)
  To: Eric Abrahamsen; +Cc: Org Mode

On Wed, Jul 30, 2014 at 2:52 AM, Eric Abrahamsen
<eric@ericabrahamsen.net> wrote:
> The vcount function will count the number of elements in a vector, so
> you could probably pass a range reference, like @1..@> (first row to
> last row) to vcount.

Yes.

> I think empty rows would be omitted, though.

It depends on whether the mode "E" is used or not, see
http://orgmode.org/manual/Formula-syntax-for-Calc.html

Michael

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

end of thread, other threads:[~2014-08-01 21:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-30  8:30 org-table Row Count Formula Esben Stien
2014-07-30  8:52 ` Eric Abrahamsen
2014-08-01 21:22   ` Michael Brand
2014-07-30  8:57 ` Thorsten Jolitz

Code repositories for project(s) associated with this 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).