AnsweredAssumed Answered

Update Field From Another Field in Hosted Feature Layer

Question asked by jpilbeam Champion on Mar 18, 2020
Latest reply on Mar 20, 2020 by jskinner-esristaff

This script successfully updates fields in a table based on other fields. I've been testing on a feature class in a FGDB, but my goal is to use this script on a hosted feature layer. For that I'd imagine working in a Jupyter notebook would be the way to go? 


import arcpy, os

fc = r'\Test\Test.gdb\survey'
fields = ['Email_Category', 'whats_your_question_about',
         'tax_related_question', 'zoning_or_flood_zone_question']

with arcpy.da.UpdateCursor(fc, fields) as cursor:
    for row in cursor:
        if row[1] == 'tax_assessment':
            row[0] = 'tax assessment'
        if row[2] == 'tax_bill':
            row[0] = 'tax bill'
        if row[3] == 'flood_zone':
            row[0] = 'flood zone'


I have Jupyter all set up and have created an item. But, if I put my script in verbatim I get this error.

RuntimeError                              Traceback (most recent call last)
<ipython-input-24-6a7e13cce2ac> in <module>
----> 1 with arcpy.da.UpdateCursor(survey, fields) as cursor:
      2     for row in cursor:
      3         if row[1] == 'tax_assessment':
      4             row[0] = 'tax assessment'
      5         if row[2] == 'tax_bill':

RuntimeError: 'in_table' is not a table or a featureclass