2

I'm trying to access the value of a column name for a specific cell in Open Refine, so I can replace the value of the cell with the column name. I'm aware of the variable row.columnNames that returns ALL column names but is there a way to return just the one for the current cell?

I'm trying to change a CSV from this:

      Col 1   Col 2   Col 3
Row1          1       2
Row2  1 

to this:

      Col 1   Col 2   Col 3
Row1          Col 2   Col 3
Row2  Col 1 

with a cell transformation like if(value != NULL, GetColumNameForCurrentCellSomehow, NULL)

If it's easier, I could also use R or Python to achieve this goal, but I have not found a straightforward way to do it there either.

Matt B
  • 45
  • 4

1 Answers1

2

Try columnName

if(value != NULL, columnName, NULL)

This does not seem to be documneted or available under the help tab. I found it by looking at: https://github.com/OpenRefine/OpenRefine/blob/c103cdcbff49cde90409855d45f4e50b5a8349d1/main/src/com/google/refine/expr/ExpressionUtils.java#L84

fadmaa
  • 3,067
  • 3
  • 18
  • 14