NumPy Array to Feature Writes only first array object to feature class

المشرف العام

Administrator
طاقم الإدارة
I am consuming a json web-service with NumPy Array to Feature, I have many nested try/except blocks to consume the data/find errors/etc. The script is functional, however I am having trouble seeing where I am obviously not accounting for a loop to consume the data.

Here is a crude example of my code structure; I am writing the first json object that I loop through to my db, although hundreds are returned. How can I adjust my code to account for all of my loops and incoming data?

import jsonimport jsonpickleimport requestsimport arcpyimport numpy as npimport timeimport datetimeimport loggingimport logging.handlersimport smtplib#overall exception handlingclass TlsSMTPHandler(logging.handlers.SMTPHandler): def emit(self, record): try: import smtplib import string # for tls add this line except: do somethinglogger = logging.getLogger()#arcpy e-mail handlingtry: def sendResultEmail(msgContents, success_TF):try: if arcpy.Exists(fc): arcpy.Delete_management(fc) try: requests stuff except requests.exceptions.ConnectTimeout as e: print "Too slow Mojo!" if last_run != now_minus_5: print "this block is activated" try: items = [] for sr in decoded2['Response']['ListOfServiceRequest']['ServiceRequest']: SRAddress = sr['SRAddress'] # SRType = sr['SRType'] if sr['Latitude'] != '': y = sr['Latitude'] if sr['Longitude'] != '': x = sr['Longitude'] if sr['Latitude'] == '': blanky = sr['Latitude'] if sr['Longitude'] == '': blankx= sr['Longitude'] print blanky print blankx #many try except blocks that consume data try: locationEwastePrevious = '' for sr in ElectronicWaste: for ewastelocation in ElectronicWaste['La311ElectronicWaste']: locationewaste = ewastelocation['CollectionLocation'] if locationEwastePrevious != locationewaste: locationEwastePrevious = locationewaste except: print "No Electronic Waste Types" try: itemEwastePrevious = '' for sr in ElectronicWaste: for ewastetype in ElectronicWaste['La311ElectronicWaste']: itemEwaste = ewastetype['ElectronicWestType'] if itemEwastePrevious != itemEwaste: itemEwastePrevious = itemEwaste except: print"No Ewaste items" try: iteminfoewasteprevious = '' countEwastePrevious = '' for sr in ElectronicWaste: for ewastecount in ElectronicWaste['La311ElectronicWaste']: countEwaste = ewastecount['ItemCount'] if countEwastePrevious != countEwaste: countEwastePrevious = countEwaste iteminfoewaste = '{0}, {1}, '.format(countEwastePrevious, itemEwastePrevious) if iteminfoewasteprevious != iteminfoewaste: iteminfoewasteprevious = iteminfoewaste ItemDesc = BulkyItemInfo + DACItemInfo outputobjects= int(decoded2['Response']['NumOutputObjects']) dt = np.dtype([('Address', 'U40'), ('LatitudeShape', '
 
أعلى