0

I'm trying to find every instances of an "Avenue #" in the Name field and have Field Calculator copy that over the single letter written in the Subname field so that both fields look exactly the same, but neither python nor visual basic are a strong suit of mine.

I need ONLY the avenue (letter) texts copied. Is there a way to do this with field calculator?

EDIT: Adding this for clarity...

I am needing only the "AVENUE #" text within the NAME field to be copied over to the SUBNAME "#" fields. The results would be an example such as this:

SUBNAME "C" = NAME "Avenue C". But SUBNAME "Avenue Belle Chase" would remain untouched.

attribute field

  • I can probably answer this, but I'm not really clear on what you are asking. Are you saying that for every instance of "Avenue #" in the [Name] field you want these entries to equal the [SubName] field contents? – GeoJohn Aug 11 '15 at 18:58
  • The other way I'm understanding your question suggests you just want both fields to be identical for every record. If that,s the case, than just field calculate the [SUBNAME] field to equal the [NAME] field. – GeoJohn Aug 11 '15 at 19:01
  • Other way around. I'd like the SUBNAME "C" to equal "AVENUE C" from the NAME field. The SUBNAME field need to have the complete Avenue # naming scheme. But only the Avenue (Letter) fields need to be the same. Every other street name within "SUBNAME" needs to remain how it is currently. And thank you for the quick response! – Jack-sum Master-null Aug 11 '15 at 19:01
  • Just go into field calculator and calculate [SUBNAME] to equal [NAME]. No python or VB required. Let me know if this answers it. – GeoJohn Aug 11 '15 at 19:04
  • 2
    what you are asking is vague! please read your post again and edit accordingly – Farid Cheraghi Aug 11 '15 at 19:04
2

My comment above provides one way to do this. If you need to do it programmatically, ensuring that only the rows that contain single letters in the table be updated then you can use the following Python in the field calcualtor.

pre-logic:

def newText(txt1, txt2):
  if (len(txt2) == 1):
    return txt1
  else:
    return txt2

execution:

newText(!NAME!, !SUBNAME!)
0

My impression of what you're saying is that for all avenues that are single letters you want only that letter to appear in subname, and for all other avenues you want the entire name copied to subname.

Make sure the parser is Python and then use the following to calculate the SUBNAME field.

Code Block:

def rename(name):
    words = name.split(" ")
    if len(words) == 2:
        if len(words[1]) == 1:
            name = words[1]
    return name

Expression:

rename(!NAME!)

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.