I am constantly stacking hundreds of columns which have common prefixes and end with a different number or suffix.
What I would like to do is write a script to:
- Find columns based on a regex pattern, e.g. "BLUE_CARS_*_\d{1,2}", "HOMES_(SINGLE|DOUBLE)_WIDE", etc.
- Select those columns
- Stack the columns (and place in a new datasheet)
For the life of me, I can't find (or Google search properly for) how to use regex with column selection.
I considered selecting the columns by data type, but there are other columns present which share that data type, not to
mention I want something much more flexible.
Any suggestions or code snippets would be immensely appreciated, and thank you in advance.