0

I'd like to automatically number a column. Similar to Excel, where I can type "1" in one cell and the cells below it automatically get numbered 2, 3, 4, 5, etc. I don't know why I'm having so much trouble figuring out this function on Openrefine but any help would be greatly appreciated.

Thanks, Gail

Gail G
  • 1

2 Answers2

1

You can add a new column ("Add new column based on this column") with this Grel formula inside :

row.index + 1
Ettore Rizza
  • 2,800
  • 2
  • 11
  • 23
  • Thanks, Ettore. The row index doesn't really correspond with the row number I'd like to assign. I generally filter the data, then assign a new set of numbers. Is there a way to do that? – Gail G Jan 17 '17 at 20:16
  • Assuming that you have good reason to not use Excel, I'm afraid that the only solution is to export the filtered rows in a CSV file and then re-import it into a new OR project. – Ettore Rizza Jan 18 '17 at 00:10
0

The answer by Ettore Rizza already provides a solution for the common case. As the question author stated in a comment it does not work for his use case. He wants to add consecutive numbers to unfiltered rows.

For this you can use records. The basic idea is to create records from the filtered data and use the record index as counter.

Steps:

  1. With filters active add a new column with the expression value.
  2. Move the new column to the beginning to use it as records.
  3. With filters still active add a new column (or transform the first one) with the expression row.record.index + 1.
Original Filtered Records Index
A A A 1
1
2
B B B 2
C C C 3
b2m
  • 529
  • 3
  • 11