OpenRefine / OpenRefine

OpenRefine is a free, open source power tool for working with messy data and improving it
https://openrefine.org/
BSD 3-Clause "New" or "Revised" License
10.86k stars 1.95k forks source link

Move a column to end via GREL without knowing the actual column count inside the project #4202

Open iomicifikko opened 3 years ago

iomicifikko commented 3 years ago

I want to move a column to end using grel without knowing the columns count inside the project.

Proposed solution

Create a "project" object (like row, record etc.) and add a "columnCount" field (similar to row.record.rowCount).

Alternatives considered

User can actually achieve the same purpose using the menu option (column > move to end) that generates a grel code based on the actual column count inside the project. This is a limitation for code portability in different projects.

Additional context

thadguidry commented 2 years ago

@iomicifikko please give us an example of what the GREL might look and where you would type the GREL into (All - Transform menu or any columns Edit cells - Transform ?) that would move a ColumnA to the last column/end or first column/beginning. Perhaps something like column.toLast("ColumnA") or column[ColumnA].toLast()?

wetneb commented 2 years ago

GREL cannot be used to move commands at all: expression languages do not have a way to change the list of columns (called ColumnModel internally). I think the grel code that @iomicifikko is refering to is the JSON representation of the operation in the undo/redo tab, which is not GREL.

So I would rephrase this request as adding the possibility to represent a "move column to the end" operation in JSON without referring to the column count of the project.

thadguidry commented 2 years ago

nit...expression languages can do whatever they are programmed for. @iomicifikko also clearly said "I want to move a column to end using grel ". But, it sounds like you would not be in favor of allowing column operations in GREL, no worries though.

At some point in the future, we will need to support columnar operations however and GREL's record handling will need to account for this.

wetneb commented 2 years ago

nit...expression languages can do whatever they are programmed for. @iomicifikko also clearly said "I want to move a column to end using grel ". But, it sounds like you would not be in favor of allowing column operations in GREL, no worries though.

Then I would be curious to have a precise description of the desired user experience for this feature (where do you click, what sort of GREL command you enter, what happens…)