Move Column to End via applied JSON

Hi-

I’m new to OpenRefine and loving it. My context is that I will be using OpenRefine to process very similar, but not identical, metadata from different digital repositories. My goal is to automate as many of the steps as possible via JSON commands. That’s mostly working out, but I can’t figure out how to move a column to the end when I don’t know the total number of columns, or add a new column and have it inserted at the end when I don’t know the current number of columns. Is there a way to tell OpenRefine to do that in a JSON command?

I’ve tried a number of things for "columnInsertIndex" when adding a new column, and "index” when moving an existing column, but haven’t hit on the right solution.

Thank you!!

Spencer

Hi Spencer,

there will be a new command available for your use case (core/column-move-last).

The code already is in the main branch of OpenRefine (see Improve generalizability of the "column move" operation by wetneb · Pull Request #7174 · OpenRefine/OpenRefine · GitHub) but I guess it is planned for the next minor release (v3.10).

For now and depending on how you create, structure and apply your JSON commands you may be able to calculate the last index by retrieving the column model (OpenRefine API | OpenRefine).

Best Benjamin

2 Likes