- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
How to replace specific words in multiple column names?
Hi all,
Is it possible to replace the column names which contains a specific word? For example, my column names are Name, Age, New_Address, New_School, New_Number. And I need to replace the word New with Current or columns that may contain the word New ---- my new column names will become Name, Age, Current_Address, Current_School, Current_Number. TIA
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to replace specific words in multiple column names?
Here is one way to do it
Names Default To Here( 1 );
dt = Current Data Table();
colNames = dt << get column names( string );
For Each( {col}, colNames,
If( Contains( col, "New" ),
Column( dt, col ) << set name( Substitute( col, "New", "Current" ) )
)
);
Jim
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to replace specific words in multiple column names?
Here is one way to do it
Names Default To Here( 1 );
dt = Current Data Table();
colNames = dt << get column names( string );
For Each( {col}, colNames,
If( Contains( col, "New" ),
Column( dt, col ) << set name( Substitute( col, "New", "Current" ) )
)
);
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to replace specific words in multiple column names?
You can also use Recode Column Names for this.
-Jarmo