Jump to content

Request for a Python Code


deepgis

Recommended Posts

Hello to all respected members,

I need your help in writing a python code to solve my problem.

I want to convert short suffix into long suffix in ArcMap field Calculator(for example in my .dbf table the street name are written as "REITTEN RD" , "E MEEKER ST" and so on . I want to convert these name in new column as "REITTEN ROAD, E MEEKER STREET and so on.

kindly help me in writing the code.

The link for .dbf table is here-

https://www.mediafire.com/?wgqz4ydctwj31w4

 

regards in advance

Link to comment
Share on other sites

I didnt check your file, but the solution is sth like this

fc = "your_featureclass"
fields = ["road_name_field"]
cursor = arcpy.da.UpdateCursor(fc, fields)

for row in cursor:
    full_name = []
    full_name = row[0].split(" ")
    road_type = full_name[-1]
    if road_type =  "ST":
        full_name[-1] = "STREET"
    elif road_type = "RD":
       full_name[-1] = "ROAD"

    result= full_name[:-1]
    result.append(full_name[-1])
    row[0]= " ".join(result)
    cursor.updateRow(row)
  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.

Disable-Adblock.png

 

If you enjoy our contents, support us by Disable ads Blocker or add GIS-area to your ads blocker whitelist