AnsweredAssumed Answered

Replace Null values with 0 in many fields

Question asked by jacobrodel on Mar 2, 2016
Latest reply on Mar 2, 2016 by jacobrodel

Can somebody point out what I am doing wrong here?  I am trying to get a list of fields (PrecipFields) and replace all null values with 0.  When I call out a specific field it works fine.  When I use list of fields it looks as if it runs but non of the values are updated. 

 

 

>>> with arcpy.da.UpdateCursor("asciiPoints",["ippt_allsites_spas1325_024_19230927_0700_UTC"]) as cursor:

...     for row in cursor:

...         if row[0] == None:

...             row[0] = 0

...             cursor.updateRow(row)

Works fine...

 

My field list I want to use...

 

>>> print PrecipFields

[u'ippt_allsites_spas1325_021_19230927_0400_UTC', u'ippt_allsites_spas1325_022_19230927_0500_UTC', u'ippt_allsites_spas1325_023_19230927_0600_UTC', u'ippt_allsites_spas1325_024_19230927_0700_UTC', u'ippt_allsites_spas1325_025_19230927_0800_UTC', u'ippt_allsites_spas1325_026_19230927_0900_UTC', u'ippt_allsites_spas1325_027_19230927_1000_UTC', u'ippt_allsites_spas1325_028_19230927_1100_UTC'

 

This is a shortened list.  There could be hundreds of fields.

 

Nothing happens...

>>> with arcpy.da.UpdateCursor("asciiPoints","PrecipFields") as cursor:

...     for row in cursor:

...         if row[0] == None:

...             row[0] = 0

...             cursor.updateRow(row)

...

Outcomes