Select to view content in your preferred language

arcpy.da.UpdateCursor too few parameters

4099
11
Jump to solution
03-16-2016 10:40 AM
JustinWolff
Regular Contributor

I'm running ArcGIS 10.3 and have a geodatabase with multiple feature datasets each containing multiple feature classes.  Each feature class has multiple string type fields containing <Null> values.  I want to change the <Null> values to "TBD" (without the quotation marks).

I feel I'm very close, but at 'for row in cursor:' I'm receiving the error "Too few parameters.  Expected 1."  I guess the cursor isn't actually returning any rows at all?  Below is what I currently have; I haven't added any documentation or messaging yet.  Any help would be greatly appreciated.

import arcpy
from arcpy import env
import os

#Set variables
inputgdb = sys.argv[1]
nullCount = 0

#Set workspace
arcpy.env.workspace = inputgdb

#Populate Nulls with TBD
datasetList = arcpy.ListDatasets(feature_type = 'feature')
datasetList = [''] + datasetList if datasetList is not None else []
for dataset in datasetList:
    env.workspace = inputgdb + "\\" + dataset
    dataset = dataset + "\\"
    fcList = arcpy.ListFeatureClasses()
    for fc in fcList:
        fc = fc +"\\"
        fieldList = arcpy.ListFields(fc,["String"])
        for field in fieldList:
            with arcpy.da.UpdateCursor (fc, 'fieldList') as cursor:
                for row in cursor:
                    if row[0] == None:
                        row[0] = 'TBD'
                        cursor.updateRow(row)
Tags (1)
0 Kudos
11 Replies
BlakeTerhune
MVP Regular Contributor

Just for future reference, you can format your code with syntax highlighting so it looks like it does in the IDE and is easier to read.

Posting Code blocks in the new GeoNet

0 Kudos
JustinWolff
Regular Contributor

Thanks Blake - applied to original post.  Working through the other suggestions/help now.  Much appreciated.

0 Kudos