I want to populate a field, named FnotExist, with values from a dictionary. I want to check if the key of the dictionary matches the row value in field FI_PATH and if it does populate the corresponding row in FnotExist. The keys in the dictionary should match row values in FI_PATH because keys were created from this field. The code below is giving me the error:

TypeError: value #1 - unsupported type: list

when it reaches the line cursor.updateRow(row)

import arcpy

arcpy.env.workspace = r"C:\TestFolder"

dbf = "ProcessControlTable"

dbf1 = "APExistOnlyEdit.dbf"

myfield = "FI_PATH"

filepathlist2 =[row[0] for row in arcpy.da.SearchCursor(dbf1,myfield)]

#Dictionary one holds field names that are within shapefile
d1 = {}

for thisFile in filepathlist2:
    ContainedFieldNames = [f.name.upper() for f in arcpy.ListFields(thisFile)]
    d1[thisFile] = ContainedFieldNames


#Dictionary two holds field names that are thought to be in shapefile
d2 = {}

    for row in rows:    
        d2[row[0]] = [a.upper() for a in row[1:] if a.strip() != '']


##Gets the difference detween dictionary two and dictionary 1
diff = {}

for key in d1:
    diff[key] = list(set(d2[key])-set(d1.get(key,[])))

with arcpy.da.UpdateCursor(dbf1, ['FI_PATH', 'FnotExist']) as cursor:
    for row in cursor:
        keyValue = row[0]
        if keyValue in diff:
            row[1] = diff[keyValue]

Below is an example of the dictionary, named diff, that I'm using to update the field FnotExist.

{'C:\\TestFolder\\Folder1\\A\\address_pt.shp': ['TYPEB', ' BUILDINGA'], 'C:\\TestFolder\\Folder1\\B\\ADDRESS_VALID_POINTS.shp': [' PRETYPEA'], 'C:\\TestFolder\\Folder1\\E\\Public_Safety_Addresses.shp': [' TYPEA']}

Below is a pic of the dbf table that I'm trying to update. The field FI_PATH was used to create the keys in the dictionary so keys should match values in row. enter image description here

I'm not sure why I'm getting an error and after research I can't figure out how to structure the code within the UpdateCursor.

  • 3
    What type of field is FnotExist? If I understand your example dictionary, you're trying to populate this field with a List (rather than a String of a list...)
    – Midavalo
    Commented Feb 1, 2020 at 4:55
  • 2
    I agree. Try converting to string: row[1]=', '.join(diff[keyValue])
    – Bera
    Commented Feb 1, 2020 at 8:04
  • 1
    Yes, I'm trying to populate the field FnotExist that accepts strings with a dictionary value that is a list of strings. @BERA Your suggestion worked. I replaced row[1] = diff[keyValue] with row[1]=', '.join(diff[keyValue])
    – user128371
    Commented Feb 1, 2020 at 14:13

1 Answer 1


As already commented and your error message suggests, you are trying to write lists (=list data type) to a string field. Convert the list to a comma seperated string with join:

row[1]=', '.join(diff[keyValue])

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.