call = Call.objects.get( event_num__iexact = row[ "EventNum" ].strip() ) action = "UPDATE" except: call = Call() action = "INSERT" call.description = row[ "Description" ] call.event_num = row[ "EventNum" ] call.report_num = row[ "ReportNum" ] call.response = row[ "Response" ] call.address = row[ "Address" ] call.zip_code = row[ "Zip" ] call.call_time = row[ "CallTime" ] call.call_type = call_type call.calltype_id = call_type.id call.beat = beat if ( row[ "Lng" ] is not None or row[ "Lng" ] != "" ) and ( row[ "Lat" ] is not None or row[ "Lng" ] != "" ): try: call.geom = fromstr('POINT(' + row[ "Lng"] + " " + row[ "Lat" ] +')', srid=4326) except: print "ERROR setting the geometry! for %s" % row[ "EventNum" ] call.jurisdiction = juri call.save() #print dir( call ) count +=1 print "%d: %s: %s" % (count, action, row["EventNum"])
else: print "using Geocoder.us lat/lng" geocoder_count += 1 new_call.geocoder = "geocoder.us" else: print "using Yahoo lat/lng" yahoo_count += 1 new_call.geocoder = "yahoo" else: print "using google lat/lng" google_count += 1 new_call.geocoder = "google" if ( lng is not None or lng != "" ) and ( lat is not None or lng != "" ): try: new_call.geom = fromstr( 'POINT(' + str(lng) + " " + str(lat) +')', srid = 4326 ) except: print "ERROR! setting the lat/lng for this call" new_call.geocoder = None geocode_error_list.append( call[ "event_num" ] ) new_call.save() #it saved so we'll put it in our success dict success_list.append( call[ "event_num" ] ) except: error_list.append( call[ "event_num" ] ) bail() output = "=================================================" output += "\r Summary of Calls Imported " output += "\r"