0

I am using a dictionary to update street type in another field in ArcGIS Pro 3.0.3

I am a novice python user and I am having problems updating a string field with a dictionary.

I am joining Transportation Injury Mapping system for California or TIMs (table) to an intersection feature class using an Unique ID. In this case, intersecting streets.

The TIMS database is composed of various street name types. For example, an Avenue may be designated as AV, ave, AVE, Ave, or Avenue, etc.

I am using dictionary to standardize the street types so I can join it to a point feature class.

In this case 'Adjusted_Road' contains the street name with street type for the key. 'Editor_Notes' will be the output field with the updated street type for the value.

I am looking for an outcome of XYZ AV (Adjusted_Road) will be XYZ Ave (Editor_Notes)

Getting an error code of:

TypeError Traceback (most recent call last)

In [10]: Line 83: cursor.updateRow()

TypeError: updateRow() takes exactly 1 argument (0 given)

import arcpy    
arcpy.env.workspace = r'I:\Projects\Warren\TIMS_GEOCODE\TIM_COLLISON_GEOCODE.gdb'
arcpy.env.overwriteOutput = True

fc = 'collisions_tims_2015_2019_fwytag_need_geo_PY'

fields = [f.name for f in arcpy.ListFields(fc)]
print(fields)

uses = {" AV" : " AVE", 
        " Avenue" : " AVE",
        " BL" : " BLVD",
        " BOULEVARD" : " BLVD",
        " ROAD" : " RD",
        " STREET" : " ST",
        " WY" : " WAY",
        "." : "",
        " DRIVE" : " DR",
        "SR-51" : "BUS 80",
        "S.R. 51" : "BUS 80",
        "SR 51" : "BUS 80",
        "STATE ROUTE 51" : "BUS 80",
        "RT " : "HWY ",
        "INTERSTATE " : "HWY ",
        "`" : "",
        " AL" : " ALY",
        "(E/B)" : "",
        "(W/B)" : "",
        "(N/B)" : "",
        "(S/B)" : "",
        " PKY" : " PKWY",
        "E/B" : "",
        "W/B" : "",
        "N/B" : "",
        "S/B" : "",
        "O/C" : "",
        " (S/R)" : "",
        "(S/R) " : "",
        "STATE ROUTE" :"HWY",
        "NORTHBOUND" : "",
        "SOUTHBOUND" : "",
        "WESTBOUND" : "",
        "EASTBOUND" : "",
        "(NORTHBOUND)" : "",
        "(SOUTHBOUND)" : "",
        "(EASTBOUND)" : "",
        "(WESTBOUND)" : "",
        "FROM " : "", #SPLIT COMMAND HERE: DELETE EVERYTHING RIGHT OF FROM
        "TO " : "", #SPLIT COMMAND HERE: DELETE EVERYTHING RIGHT OF TO
        "STATE ROUTE-51" : "",
        "TRANSITION" : "",
        "()" : "", #DELETE VARATION
        "OFF RAMP" : "",
        "ONTO" : "",
        " PARKWAY" : " PKWY",
        "HIGH WAY 50" : "HWY 50",
        "HIGH WAY 16" : "JACKSON RD",
        }


usesKey = list(uses.keys())

usesvalues = list(uses.values())


fields = ['Adjusted_Road_1', 'Editor_Notes'] #review
          
with arcpy.da.UpdateCursor(fc, fields) as cursor:
    for row in cursor:
        raw_name = row[0]
        out_name = raw_name
        for key in usesKey:
            if key in raw_name:
                new_val = uses[key]
                out_name = out_name.replace(key, new_val)
        row[1] = out_name
        cursor.updateRow()

1 Answer 1

1

Where you have:

cursor.updateRow()

you should try:

cursor.updateRow(row)

The former is not providing an argument to the updateRow method of your cursor object whereas the latter does.

0

Your Answer

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

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