0

I have a very large dataset in ArcMap 10.6 and I would like to create a subset that selects only rows that have specific attributes (some of them with special characters) from a field that in my case has a list of multiple codes and words.

Example:

Let's say that I want a dataset that contains only the rows with the code BMX-3000 and INDEX-AB, but not other values.

example

Can anybody suggest me a relevant code query or model creation steps?

2

Try this python function in Field Calculator:

def replaceValue(attr):
  keep = ['BMX-3000', 'INDEX-AB', 'otherValue']
  for val in keep:
    found = attr.find(val)
    if found > -1:
      return val
  if found == -1:
    return attr

function call =

replaceValue(!fieldNameToCheckAgainst!)

  • Hi artwork21, thanks for your answer. Where do I type "function call = replaceValue(!fieldNameToCheckAgainst!)" ? – Geo_explorer Sep 9 at 8:57
  • When you open the tool click the Pre Logic checkbox, the code goes in the large top box and the function call goes in the smaller bottom one. Make sure you select the python parser option too. – artwork21 Sep 9 at 12:26
  • What if some rows have: BMX-3000, NAB-H, INDEX-AB. and I want to obtain: BMX-3000, INDEX-AB? The code currently deletes INDEX-AB if it is in the row after BMX-3000, . – Geo_explorer Sep 13 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.