AnsweredAssumed Answered

UpdateCursor With a Hosted Table

Question asked by jpilbeam Champion on Jul 8, 2020
Latest reply on Jul 8, 2020 by j0shNZ

I'm trying to populate the 'Description' field in the Recycling Locations View layer (a hosted Feature Layer) with the text from the 'Description' field in the Green Descriptions layer (a hosted Table). The 'Category' field from both have the same values.

 

 

The script I have uses the UpdateCursor to populate a field based on another field from the same Feature Layer. I think I can create a list with the text from the 'Description' field, but that seems redundant seeing as though there is probably a way to bring it in straight from the hosted table?

import arcpy, requests, json

#disable warnings
requests.packages.urllib3.disable_warnings()

#Recycling Locations Feature layer
fc = survey_item

#text to populate the Description field of the Recycling Locations layer
descriptions = ['Refrigerators, stoves, dishwashers, water heaters and other large appliances are considered white goods and are banned from landfills. Hazardous components such as mercury, CFCs and PCBs are dangerous and require proper handling and disposal. When purchasing an appliance, request the company to take your “old” appliance or contact your city/village. A list of certified Freon removal specialists is not currently available. The U.S. EPA administers a program to certify technicans. Their requirements can be found at http://www.epa.gov/Ozone/title6/608/608fact.html#techcert',
               'ASBESTOS - Asbestos is a naturally occurring mineral found in certain rocks. Asbestos was commonly used in home building materials before the mid-1970s and occasionally until the late 1980s because it is strong, fire- and corrosion-resistant and a good insulator. If asbestos is in good condition and left in place, it should not present health risks. However, if a building is going to be demolished, renovated, or remodeled, care should be taken to prevent the release of asbestos fibers into the air. Inhalation of microscopic asbestos fibers can cause health risks. You may search for Licensed Asbestos Professionals in the Yellow Pages or call the Illinois Dept. of Public Health.',
               'In most cases older vehicles are traded-in or brought to an auto salvage yard; or you may choose to donate them for parts reuse and recycling. Contact the following organizations to make arrangements, get paid or ask about tax deduction information.',
               ... etc.
               ]

#fields from the Recycling Locations layer
fields = ['Description', 'Category']

#use the updatecursor to populate the Description field from the descriptions list
with arcpy.da.UpdateCursor(fc, fields) as cursor:
     for row in cursor:
         if row[1] == 'Appliance Recycling':
            row[0] = descriptions[0]
         elif row[1] == 'Asbestos Info / Removal Service':
            row[0] = descriptions[1]
         elif row[1] == 'Automobile & Boat Reuse Recycling':
            row[0] = descriptions[2]
         cursor.updateRow(row)
del cursor

Outcomes