0

I have more than 100 columns in dataprep whose names are like:

my column name 1

my column name 2

I would like to rename the name of the columns to be:

my_column_name_1

my_column_name_2

I have tried to do a rename, changing " " by "_". However, dataprep only changes the first whitespace! Is there any way to change all the whitespaces?

Another question, when I do a function like rename, it is done just for a column. I can add more columns writing the name of de column. Is there any way to select all columns without writing all the names?

thank you so much!

jonaetn
  • 9
  • 4
  • Following the steps in the [documentation](https://cloud.google.com/dataprep/docs/html/Rename-Columns_57344591#batch-rename-methods) also results in only the first occurrence being changed. I reported the [issue](https://issuetracker.google.com/119735507) to Dataprep. You can [subscribe](https://developers.google.com/issue-tracker/guides/subscribe#starring_an_issue) to updates by clicking the star at the top of the page. For the time being, although inconvenient, repeating the rename column step 3 times will properly change the column name. – Atybzz Nov 18 '18 at 22:02

2 Answers2

2

You can shift-select multiple columns to Transform when the data is in column view mode.

Column Browser

Select the columns to apply to and then choose the transformation.

JSDBroughton
  • 3,966
  • 4
  • 32
  • 52
  • In the Trifacta wrangle language, there is the possibility to specify a range of columns by name, but this doesn't appear to be available in Dataprep. If I find later this is not the case I'll update this answer – JSDBroughton Nov 16 '18 at 14:06
  • How do you select all – WJA Feb 18 '19 at 18:21
1

JSDBroughton answer did the trick for me although it's not so clear how to do it. Change your view to Columns (second icon from the left on the toolbar). Select the first column, then hold Shift and select the last column. You should now have all columns selected. Then right clock and select Rename. A new Recipe step will be added with all your columns already added. Then set the Option to "Find and replace".

In terms removing all the spaces I couldn't find any Cloud Dataprep pattern or Regular Expression which let me replace all my spaces in my columns. Having said that my columns had a maximum of 4 spaces so I simply added the same step multiple times. I used the Regular Expression \s to match spaces and I replaced them underscores.

enter image description here

GreenLantern22
  • 489
  • 5
  • 10
  • This information about the regex replace in column names is correct. I have submitted a feature request to allow for multiple replacements as per the field replace text function. +1 – JSDBroughton Feb 05 '19 at 18:57
  • [Renaming columns using Find and Replace and Regular Expressions](https://community.trifacta.com/s/question/0D51L00005npVC0SAM/) – JSDBroughton Feb 05 '19 at 19:07
  • Isnt there a way to rename all by default. I use pivotting and have dynamic number of columns... – WJA Feb 28 '19 at 18:01