mid

826
4
Jump to solution
09-18-2019 04:51 PM
kenWILKINS
New Contributor II

I'm doing a calculated field in Arcgis 10x desktop. 

ROOTID field is a parcel ID (from another organization).   example:  06-07- 43-0462-0000-0000

I'm changing the number in the field ASI_PID to be calculated to be:    07  43046200000000

ASI_PID is type: String and length=50

My calc is:    Mid([ROOTID],4,2)+" "+Mid([ROOTID],8,2)+Mid([ROOTID],11,4)+Mid([ROOTID],16,4)+Mid([ROOTID],21,4)

But I get:   07  4-048-000-000     I don't want the dashes, and as you can see, I'm not adding any.  I'd like a space after the first two numbers.   I tried changing how many numbers at the position (like 4,5) but it still puts in the dash and leaves out a number.


What am I doing wrong?

Thank you!

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

Ken

tick python on

dump your expression from the last line and replace with mine

there is no prelogic code block

"".join([str(i) for i in !ROOTID!.split("-")[1:]])

View solution in original post

4 Replies
DanPatterson_Retired
MVP Emeritus

python parser

rootid = '06-07- 43-0462-0000-0000'  # which would be !rootid! in the expression

"".join([str(i) for i in rootid.split("-")[1:]])
'07 43046200000000'
0 Kudos
kenWILKINS
New Contributor II

Dan,

Thanks for the reply. I don’t speak Python. Do I add this in the codeblock with my expression in the calc field ? See pic

Thank you

Ken Wilkins

Hurricane, WV

0 Kudos
DanPatterson_Retired
MVP Emeritus

Ken

tick python on

dump your expression from the last line and replace with mine

there is no prelogic code block

"".join([str(i) for i in !ROOTID!.split("-")[1:]])
kenWILKINS
New Contributor II

Thank you!    I ran mine first to get the numbers, then ran yours to eliminate the dashes.

Thanks!

0 Kudos