OpenRefine: Variable columnNames is not available in Jython
The variable columnNames is not available in Jython, whereas it is available in GREL. It is useful to iterate over all cells in a row, for instance with this expression:
forEach(row.columnNames,cn,cells[cn].value)
(see https://groups.google.com/g/openrefine/c/gV0bLUz7p7o)
Proposed solution
We could make this variable available in Jython too. It would also be good to document which variable names (and fields) are available in Jython, if this is really meant to differ from what is available in GREL.
Alternatives considered
Make sure all variables and fields offered in GREL are also available in Jython and Clojure.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 18 (14 by maintainers)
I’m not very familiar with the Jython integration but I think the code that @wetneb is referring to is here https://github.com/OpenRefine/OpenRefine/blob/ab59b30a4527e844dd7ab37f2e56845b12effee0/extensions/jython/src/com/google/refine/jython/JythonEvaluable.java#L99
This (if I’m reading it correctly) creates a python function that accepts a set of arguments which correspond to the GREL variables that can then be used in the function. Then further down the file there is the
evaluatemethod which defines the bindingsOthers maybe able to confirm or correct my reading of the code
Adding a
columnNamesparameter in the JythonEvaluable sounds appropriate indeed. Good luck!Yes @Binita-tech.
It’s both. Adding code so Jython can handle the variable, and adding the corresponding documentation.
For the documentation, you could also document all the variables available in Jython. But it is not required, another issue could be opened for that.
Regards, Antoine