How to delete empty columns / conditional delete of column basic on text string?

Hi,
Is there a way to delete empty columns?

The use case is that I have a very large CSV file which endless amount of columns of which many are empty. Instead of one by one selecting which columns to keep or delete, I’d like to delete all empty columns in one go.
Is this possible?

Secondly, I’d love conditional delete of columns in general terms. For example to delete any column which has a specific text string or combination of strings.
Perhaps this exists too? If not I’ll make a feature request of it. It would also tackle the first point in my questions.

Thanks for your help.

Hi @Paul1 :wave: welcome to the community!

This is a great question. We are able to use the flip tables step and filtering to remove blank columns. In this example, I created a dataset with blank columns spread throughout:

First, we use the “Flip Table” step to pivot our data. Notice that our headers are now in the first column:

We can then filter to find rows where the value in the second column is not blank:

Finally, we flip the table back to its original orientation with another “Flip Tables” step. As long as your data has unique values in the first column, you should be done at this point.

If your data does include numbered values (duplicate cells in column 1 that are numbered with (1), (2), etc.), you can use an “Extract Text from Column” step to find all text before “(”, then remove the first column with a “Select Columns” step.

This approach would also work for conditionally deleting columns – instead of filtering to keep rows where the second column is not blank, you could filter to remove rows that contain a certain string.

Hope this helps! Let me know if you have any additional questions.

Hi Adam,
Thanks so much for your clear and concise explanation.

Having said that, it feels a lot like a workaround :wink:

It would be much more straightforward if you had a ‘filter columns’ feature with the same functionality as ‘filter rows’ applied to columns.

I vouch for it :wink:

Hi Paul,

My pleasure – you’re certainly right about this being workaround!

Feel free to submit a request for this feature and our product team will be sure to consider the request. Hope this approach works for you in the meantime!

Sure! I added the feature request here:

2 Likes