all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Including row numbers in a table
@ 2008-08-09  4:40 Daniel J. Sinder
  2008-08-09  5:59 ` Bernt Hansen
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel J. Sinder @ 2008-08-09  4:40 UTC (permalink / raw)
  To: emacs-orgmode

I haven't used table formulas that much and I can't figure this one 
out.  I'd like to include row numbers in the table itself. 
Something like this:

   | Row | Data Column 1  | Data Column 2       |
   |-----+----------------+---------------------|
   |   1 | some data      | more data           |
   |   2 | some more data | even more data      |
   |-----+----------------+---------------------|
   |   3 | still more     | yup, you guessed it |
   |   4 | and more       | that's all          |


I'd like to use a formula for the first column so that if I move 
rows around using org commands, the row numbers can be easily 
re-calculated.  Note that I'd like numbering to continue 
sequentially across horizontal lines.

I've tried column formulas like @-1+1, but the horizontal lines get 
in the way.  And if every row needs it's own formula, it's hardly 
better than just filling in the numbers.

Can anyone suggest how to do this is a reasonably automated fashion?

Thanks,
Dan

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

* Re: Including row numbers in a table
  2008-08-09  4:40 Including row numbers in a table Daniel J. Sinder
@ 2008-08-09  5:59 ` Bernt Hansen
  2008-08-09  6:57   ` Bernt Hansen
  0 siblings, 1 reply; 5+ messages in thread
From: Bernt Hansen @ 2008-08-09  5:59 UTC (permalink / raw)
  To: Daniel J. Sinder; +Cc: emacs-orgmode

"Daniel J. Sinder" <djsinder@gmail.com> writes:

> I haven't used table formulas that much and I can't figure this one
> out.  I'd like to include row numbers in the table itself. Something
> like this:
>
>   | Row | Data Column 1  | Data Column 2       |
>   |-----+----------------+---------------------|
>   |   1 | some data      | more data           |
>   |   2 | some more data | even more data      |
>   |-----+----------------+---------------------|
>   |   3 | still more     | yup, you guessed it |
>   |   4 | and more       | that's all          |
>
>
> I'd like to use a formula for the first column so that if I move rows
> around using org commands, the row numbers can be easily
> re-calculated.  Note that I'd like numbering to continue sequentially
> across horizontal lines.
>
> I've tried column formulas like @-1+1, but the horizontal lines get in
> the way.  And if every row needs it's own formula, it's hardly better
> than just filling in the numbers.
>
> Can anyone suggest how to do this is a reasonably automated fashion?
>


  | Row | Data Column 1  | Data Column 2       |
  |-----+----------------+---------------------|
  |   1 | some data      | more data           |
  |   2 | some more data | even more data      |
  |-----+----------------+---------------------|
  |   3 | and more       | that's all          |
  |   4 | still more     | yup, you guessed it |
  |-----+----------------+---------------------|
#+TBLFM: $1=find(@I$2..@III$2,$2)

This assumes the data in Data Column 1 ($2) is unique

-Bernt

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

* Re: Including row numbers in a table
  2008-08-09  5:59 ` Bernt Hansen
@ 2008-08-09  6:57   ` Bernt Hansen
  2008-08-09  7:04     ` Bernt Hansen
  0 siblings, 1 reply; 5+ messages in thread
From: Bernt Hansen @ 2008-08-09  6:57 UTC (permalink / raw)
  To: Daniel J. Sinder; +Cc: emacs-orgmode

Bernt Hansen <bernt@norang.ca> writes:

> "Daniel J. Sinder" <djsinder@gmail.com> writes:
>
>> I'd like to use a formula for the first column so that if I move rows
>> around using org commands, the row numbers can be easily
>> re-calculated.  Note that I'd like numbering to continue sequentially
>> across horizontal lines.
>>
>> I've tried column formulas like @-1+1, but the horizontal lines get in
>> the way.  And if every row needs it's own formula, it's hardly better
>> than just filling in the numbers.
>>
>> Can anyone suggest how to do this is a reasonably automated fashion?
>>
>
>
>   | Row | Data Column 1  | Data Column 2       |
>   |-----+----------------+---------------------|
>   |   1 | some data      | more data           |
>   |   2 | some more data | even more data      |
>   |-----+----------------+---------------------|
>   |   3 | and more       | that's all          |
>   |   4 | still more     | yup, you guessed it |
>   |-----+----------------+---------------------|
> #+TBLFM: $1=find(@I$2..@III$2,$2)
>
> This assumes the data in Data Column 1 ($2) is unique


This works better.  It doesn't assume anything about the data and you
can add as many horizontal lines as you want in the table.  This also
removes the requirement for the trailing horizontal line from the
previous solution.

  | Row | Data Column 1 | Data Column 2 |
  |-----+---------------+---------------|
  |   1 | x1            |               |
  |   2 | some data     | more data     |
  |-----+---------------+---------------|
  |   3 |               |               |
  |   4 |               |               |
  |   5 |               |               |
  |   6 |               |               |
#+TBLFM: $1=vlen(@I$2..0)/2;EN

-Bernt

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

* Re: Including row numbers in a table
  2008-08-09  6:57   ` Bernt Hansen
@ 2008-08-09  7:04     ` Bernt Hansen
  2008-08-09  8:16       ` Daniel J. Sinder
  0 siblings, 1 reply; 5+ messages in thread
From: Bernt Hansen @ 2008-08-09  7:04 UTC (permalink / raw)
  To: Daniel J. Sinder; +Cc: emacs-orgmode

Bernt Hansen <bernt@norang.ca> writes:

> This works better.  It doesn't assume anything about the data and you
> can add as many horizontal lines as you want in the table.  This also
> removes the requirement for the trailing horizontal line from the
> previous solution.
>
>   | Row | Data Column 1 | Data Column 2 |
>   |-----+---------------+---------------|
>   |   1 | x1            |               |
>   |   2 | some data     | more data     |
>   |-----+---------------+---------------|
>   |   3 |               |               |
>   |   4 |               |               |
>   |   5 |               |               |
>   |   6 |               |               |
> #+TBLFM: $1=vlen(@I$2..0)/2;EN

Last one... *honest*

  | Row | Data Column 1 | Data Column 2 |
  |-----+---------------+---------------|
  |   1 | x1            |               |
  |   2 | some data     | more data     |
  |-----+---------------+---------------|
  |   3 |               |               |
  |   4 |               |               |
  |   5 |               |               |
#+TBLFM: $1=vlen(@I$1..0);EN

-Bernt

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

* Re: Including row numbers in a table
  2008-08-09  7:04     ` Bernt Hansen
@ 2008-08-09  8:16       ` Daniel J. Sinder
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel J. Sinder @ 2008-08-09  8:16 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode

Bernt Hansen wrote:
> Bernt Hansen <bernt@norang.ca> writes:
> Last one... *honest*
> 
>   | Row | Data Column 1 | Data Column 2 |
>   |-----+---------------+---------------|
>   |   1 | x1            |               |
>   |   2 | some data     | more data     |
>   |-----+---------------+---------------|
>   |   3 |               |               |
>   |   4 |               |               |
>   |   5 |               |               |
> #+TBLFM: $1=vlen(@I$1..0);EN

Thanks for all three solutions -- I'm using the last one and it 
works great!  (I think the '$1' is superfluous).

Dan

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

end of thread, other threads:[~2008-08-09  8:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-09  4:40 Including row numbers in a table Daniel J. Sinder
2008-08-09  5:59 ` Bernt Hansen
2008-08-09  6:57   ` Bernt Hansen
2008-08-09  7:04     ` Bernt Hansen
2008-08-09  8:16       ` Daniel J. Sinder

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.