1

I have a file with 76 columns, out of which 52 columns are irrelevant and should be removed based on their column headers (i.e. string of names). OpenRefine offers the possibility to manually Re-order/remove columns but I was wondering if there is a GREL way to match header names and remove many columns at once, as I was not able to find a remove function similar to replace.

Erfanesi
  • 11
  • 1
  • 1
    Unfortunately no, you will have to delete them manually. But when you import a CSV file, you can specify the list of columns to import. – Ettore Rizza May 04 '20 at 10:42
  • Second try with a hackish solution : https://groups.google.com/d/msg/openrefine/80zQmoX7Ec8/PLdAcsehBwAJ – Ettore Rizza May 04 '20 at 12:38

2 Answers2

2

If the columns that you want to remove are in sequence, you can use Transpose -> Transpose cells across columns into rows

Then do the following:

From Column: First column you want to delete

To Column: Last column you want to delete

Transpose Into: Two new columns

  • Set the Key column to anything - e.g. A
  • Set the Value column to anything - e.g B

Now all of the columns you want to delete have been turned into rows and have been replaced by A and B. Finally, delete A and B and you're done.

Adi Eyal
  • 183
  • 9
  • 1
    I really like this "hack"! Even when the columns are not in sequence you can use Textfilter, TextFacets and so on on the key column to (mass-)delete rows and for the remaining rows go back to the column format via "Transpose" => "Columnize by key/value columns..." – b2m Jun 03 '22 at 12:48
0

Did you try the menu options on the All column? All --> Edit Columns --> Re-order/Remove columns...

Thad Guidry
  • 579
  • 4
  • 8
  • Yes, but it is tedious to drag and drop more than 50 columns manually using Re-order/Remove. It seems there is no such functionality or other solution in OpenRefine to tackle this. – Erfanesi May 05 '20 at 07:18
  • Some options I also thought of that we could add based on your need:
    1. So you want a new Column Remove function introduced into GREL that can take a parameter for the Regex pattern to search Column names and remove those columns that match the pattern?
    2. Perhaps the Re-order/Remove columns can have a new input box to type in that Regex pattern you wish to search on to remove the columns?
    How do you envision this new functionality ideally working for you?
    – Thad Guidry May 25 '20 at 15:40