2

I am trying to make use of a codeblock found in this thread:

Removing numeric characters from alphanumeric value in field calculation?

I put this code into the pre-logic script field of the field calculator:

import re 
def strip_digits(s):
 return re.sub("\d+", "", s)

And call it in the expression as below with the column in question substituted for column_name:

strip_digits(!column_name!)

And get the following when running it on a column of data type long:

ERROR 000539: Error running expression: strip_digits(171752)<type 'exceptions.TypeError'>:expected string or buffer

I can't seem to figure out what is going wrong, any ideas?

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Aug 31, 2015 at 17:36
2
  • What is the name of the column ? Commented Aug 31, 2015 at 19:53
  • Column name is SITE. Commented Sep 8, 2015 at 23:39

1 Answer 1

4

Your input and output column should be text type. It's expecting a string or buffer and you passed probably integer or double.

answered Aug 31, 2015 at 18:06
1
  • That's it, column type is long interger. Didn't know that allowed text...an example of the data is '1120 - Mesic Hammock'. Commented Sep 8, 2015 at 23:58

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.