The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
Using regex for generating generic column names by
fernando_lopezr
Member Posts: 2 Contributor I
Hi everyone, I am trying to make a join on two tables that share not only Key attributes but column names, e.g 1960, 1961..., 2010 (although column values differ in both tables). After doing the join I got a table with duplicate column names, but different data. I want to name one set o these columns as p1960, p1961,...p2010 letting the other as is. I have tried the tool Replace by Generic name and put this regex in the generic name field p\b(19[6-8][0-9]|199[0-9]|200[0-9]|201[0-7])\b but It didn't work. Any help is appreciated.
Thanks!
Thanks!
Tagged:
0
Best Answer
-
Telcontar120 RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,635 UnicornI think you have overcomplicated this.
You just need to set the capture group to whatever the existing attribute name is and then replace with p plus the original capture group. So in the Rename by Replacing operator, you set the "replace what" to (.+) and then "replace with" to p$1 and it should work fine. Note that you may need to filter for only the attributes you want to do this for if there are other attributes in the dataset that you don't want to rename in that fashion, but you can do that in the same operator in the first parameter by just selecting the attributes using the regex for 4 sequential digits which is [0-9]{4}6
Answers