Add a prefix under certain conditions

Hello, dear EDT experts!

I am now actively studying EDT, I like a lot, but there are questions that I cannot solve. Next, I will give one of the questions. I need to separate Number and Email from one column (Data) into separate columns. I’ve done a number of transformations, probably not in the best way, and if someone optimizes the process, I’d appreciate it.

I still have an unresolved question - in the Number field, if the number is 8 digits long, then 682 should be added before it. If the length is more or less than 8 digits, then you do not need to add anything.

The final table should look like this.
|Isabella|68224837459|
|Daniel|68224803622|
|William|admin@gmail.com |
|Olina|54720035181|
|Jacob|antarctic@yahoo.com |

|Name|Data|
NumberEmailres.transform (6.0 KB)

I will be very grateful if you can suggest a solution.

To prepend “682” to any string 8 characters long, use a Calculate transform to calculate text Length and then use an If transform to prepend.

New .transform attached.

NumberEmailres2.transform (6.1 KB)

1 Like

Hi,

Here is the transform you are looking for.

Transform File
NumberEmailres.transform (3.7 KB)

1 Like

Hi,

Better use this transform, as it is safe and was my first solution, but wanted to try out the Replace Transform and it does work, but it has a flaw and let see if you or others can catch it.

Transform File
NumberEmailres2.transform (3.7 KB)

1 Like

Good afternoon!
Happy New Year!
Thank you very much for a very quick answer, which helped me a lot in solving the issue.
I will use it!

Greetings!
Happy New Year!
I want to thank you for your practical help. It helped me a lot, though I made a mistake in my example. I am interested in having Email Number in separate columns, so I have supplemented your solution a little.
Both of your options are working, but so far, unfortunately, I don’t have enough knowledge of EDT to find any flaw. I’ll try it on large tables and maybe then I’ll see something.
Thank you very much again!


NumberEmailresClear.transform (6.0 KB)

1 Like

Here is simpler version, I made number and email separate initially, but your final result was all in one column so I created the solution accordingly, but if you want number and email separate then here it is

Transform file
NumberEmailres3.transform (3.7 KB)

1 Like

Thank you very much for sending an improved solution. Everything works perfectly!

2 Likes