Options

[SOLVED] Replacing the international code of a telephone number

Kate_StrydomKate_Strydom Member Posts: 19 Contributor II
edited November 2018 in Help
Hi,

I am battling to replace the first two digits (international code) of a mobile phone number, for example, 27766270940 without RM replacing the other set of 27 within the number.
I need the mobile number to become 0766270940.

Can anyone assist me?

Thanks
Kate

Answers

  • Options
    sgenzersgenzer Administrator, Moderator, Employee, RapidMiner Certified Analyst, Community Manager, Member, University Professor, PM Moderator Posts: 2,959 Community Manager
    If it were me, I would make it a nominal attribute (if not already) and generate a new attribute where the function would be concat("0",suffix(att1,9))

    Scott
  • Options
    Kate_StrydomKate_Strydom Member Posts: 19 Contributor II
    Thanks Scott. Your approach works well.  :)

    My attribute is already nominal. I was trying to use a start and replace function but they were not working very well.

    Now I have some mobile numbers that need to be excluded or replaced as missing, once I have applied your approach. Basically I need to exclude any number with 00 or 01.

    This expression  if(prefix(mobile_number, "00"), " ", if( prefix(mobile_number, "01"), " ", mobile_number) is giving me errors.

    Any suggestions?

    Kate
  • Options
    MartinLiebigMartinLiebig Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,511 RM Data Scientist
    Hi Kate,

    i think you simply forgot a paranthesis. This should work:

    if(prefix(mobile_number, "00"), " ", if( prefix(mobile_number, "01"), " ", mobile_number))
    you can by the way split this into two parts in Generate Attributes. Than it is a bit more readable.

    Cheers,

    Martin
    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany
  • Options
    Kate_StrydomKate_Strydom Member Posts: 19 Contributor II
    Hi Martin,

    My error when typing out the function. Sorry :o.

    When I was driving home last night I realised that the prefix function is the problem. I cannot use a prefix to identify the 00 and 01 as this function will keep the first two digits. I want it to identify the first two digits and then exclude the ones that are not valid.

    Got it. Now Scott's approach works perfectly for me.

    if(starts(mobile_number, "00") || starts(mobile_number, "01") || starts(mobile_number, "02") || starts(mobile_number, "04"), " ", mobile_number)
    Thanks Scott and Martin for your contribution; :D . It was a great help when you are all alone behind a pc with no other RM person to bounce ideas off.

    Regards,
    Kate
  • Options
    MartinLiebigMartinLiebig Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,511 RM Data Scientist
    No problem! it is always great to see, that people use our product!
    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany
Sign In or Register to comment.