cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Rename to add Spaces?

SOLVED
Bren312
Asteroid

Dynamic Rename to add Spaces?

Hi all, I've got a question regarding the Dynamic Rename tool which I'm hoping to get some help with.  I'm importing a CSV file which has all Column Header titles mashed together like so:  VendorClaimNumber; ItemName; CountryClaim, etc.

 

I'm looking for a way to dynamically add a space between the Capital Letters to change the headers to Vendor Claim Number, Item Name, etc.  

 

I've tried a REGEX_Replace ([_CurrentField_],"\u","\s") and that didn't do it...any ideas?  Thanks everyone!

 

Bren

Attachment
Download this attachment
6 REPLIES 6
Bren312
Asteroid

Dynamic Rename to add Spaces?

Hi all, I've got a question regarding the Dynamic Rename tool which I'm hoping to get some help with.  I'm importing a CSV file which has all Column Header titles mashed together like so:  VendorClaimNumber; ItemName; CountryClaim, etc.

 

I'm looking for a way to dynamically add a space between the Capital Letters to change the headers to Vendor Claim Number, Item Name, etc.  

 

I've tried a REGEX_Replace ([_CurrentField_],"\u","\s") and that didn't do it...any ideas?  Thanks everyone!

 

Bren

Attachment
Download this attachment
CharlieS
17 - Castor

Re: Dynamic Rename to add Spaces?

Hi @Bren312 

 

I used a few more tools than just a Dynamic Rename, but it should be easy to follow. Check out the attached workflow to see how I used RegEx to identify capitalized words, rebuild them with spaces, and rename all the fields of the original data stream.

 

20200309-RenameWithSpaces.PNG

Attachment
Download this attachment
MarqueeCrew
20 - Arcturus

Re: Dynamic Rename to add Spaces?

@Bren312 ,

 

This is more involved because you need to dynamically address the replacement of Capital Letters with SPACE+Capital Letter (except the first).  I created a replacement table for field names as shown below:

 

capture1.png

 

I hope that this helps and possibly teaches you something.  If someone else comes up with a cleaner solution, I'll be interested.

 

Cheers,

 

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Attachment
Download this attachment

Re: Dynamic Rename to add Spaces?

@CharlieS ,

 

In my solution I accept values with spaces as names and don't mess with them.  I know that it wasn't a stated requirement, but I did add that feature.

 

Cheers,


Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.

Re: Dynamic Rename to add Spaces?

Top notch; thanks Mark!  Your workflow definitely taught me some things and I appreciate you taking a look at this.  Thanks again and all the best!

 

Bren

Re: Dynamic Rename to add Spaces?

Hi Charlie, thanks for taking a look at this.  I like your solution; it's pretty sleek.  Thanks again and all the best!

 

Bren

kpayne
5 - Atom

Re: Dynamic Rename to add Spaces?

Thank you!! This was exactly what I was looking for. Smiley Happy  Worked perfectly.