add dots between numbers in attribute field

333
3
09-29-2023 02:58 AM
Labels (3)
lbuava
by
New Contributor

hello guys i need to add dots between numbers in attribute field data for example i have 1234567890 and in need something to meke it like this: 12.34.567.890 for example. vb scrypt or python

Tags (2)
0 Kudos
3 Replies
JimCousins
MVP Regular Contributor

Ibuava,

The result of this operation will be a string. Numeric values do not have "dots" in them. Within python, as a string, you can use a simple string slice and append function, such as:

oldNum = str(1234567890)
newNum = oldNum[:2] + "." + oldNum[2:4] + "." + oldNum[4:7] +"." + oldNum[7:]
newNum
'12.34.567.890'

This assumes the oldNum is 10 characters in each entry.

If it is not always10 characters, work from the end of the string value to the front, instead.

If you are trying to do something else, please provide more information so you can get a targeted response to your question.

Regards,

Jim

 

lbuava
by
New Contributor

thanks for your response, that is exactly what i need but i have big date over 20K, i need to do this for all of them. Will this function work for all of them?

0 Kudos
JimCousins
MVP Regular Contributor

Yes, it should not be an issue.

NOTE: You should create a new field and calculate it based off of the original, so if there are any problems, you still have access to the original source field and values.

0 Kudos