call_type = CallType.objects.get( name__iexact=row[ "CallType" ].strip().upper() )
		#print "FOUND call_type: %s" % call_type
	except:
		print bail()
	
	try:
		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
	
Beispiel #2
0
				#print "UPDATING call: %s" % call[ "event_num" ]
				#update_count += 1
			#else:
			skip_count +=1 
			print "SKIPPING call: %s" % call[ "event_num" ]

		except:
			try:
				new_call = Call()
				print "creating call for " + call[ "event_num" ]
				#call was created. lets set all our shit about it
				new_call.calltype = calltype
				new_call.beat = beat
				new_call.jurisdiction = juri
				new_call.event_num = call[ "event_num" ]
				new_call.response = call[ "response" ]
				new_call.description = call[ "description" ]
				if call[ "address" ] != "" and call[ "address" ] is not None:
					call[ "address" ] = call[ "address" ].replace( "&", " & ")
					call[ "address" ] = call[ "address" ].replace( "US65", "US 65" )
					call[ "address" ] = call[ "address" ].replace( "JRF","James River Freeway" )
					#for some reason there is a bunch of addresses that are like "N; Boonville instead of just N Boonville"
					call[ "address" ] = call[ "address" ].replace( ";", "" )
				
				new_call.address = call[ "address" ]
				
				new_call.report_num = call[ "report_num" ]
				call_time = time.strptime(call[ "call_time" ],"%m/%d/%y %I:%M:%S %p")
				new_call.call_time = time.strftime("%Y-%m-%d %H:%M:%S",call_time)
				try:
					place, ( lat, lng ) = g.geocode( call[ "address" ] + " Springfield, MO",exactly_one=True )