CONCATENATE PRE LOGIG THREE FIELDS ARCGIS

495
1
05-27-2020 06:05 AM
PintoJoão
New Contributor II

HI PEOPLE OF GIS

I Want join Predio field and the Key field to the ID_GESSERV field. I was doing this join in excel based on the formulas, LEFT, RIGHT, MID and CONC.

I need the concatenation to always fill the "ID_PREDIO" field with 4 digits,

I think there must be a logical script for this that should be based on if> 1000 and <100 = 0 more the "ID_PREDIO" number. If> 1000 and <10 = 00 is the value of the "ID_PREDIO".

If> 1000 and <9 = 000 and the value of the "ID_PREDIO"

for example:If I receive the value 8 in the ID_PREDIO field, the concatenation will have to add 3 zeros. If you receive the value 190 the concatenation will have to add 1 zero.

enter image description here

Thanks a lot

0 Kudos
1 Reply
DanPatterson
MVP Esteemed Contributor
a = [1, 11, 111, 1111]

s = "E000186"

e = 0

["{}{:>04}{}".format(s, i,  e) for i in a]
Out[14]: ['E00018600010', 'E00018600110', 'E00018601110', 'E00018611110']

The key is the '0' padding in the middle variable, represented by 'a' above.

s is the start, e is the end values


... sort of retired...