emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] org-table Row Count Formula


From: Thorsten Jolitz
Subject: Re: [O] org-table Row Count Formula
Date: Wed, 30 Jul 2014 10:57:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Esben Stien <address@hidden> 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




reply via email to

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