示例#1
0
			EffortInstanceObj.provider_type = 'CL'
			#print 'clinic recorded'
		
		#cool way to make Service Providers unique, if obj does not exist then it creates it.
		#https://docs.djangoproject.com/en/1.6/ref/models/querysets/#get-or-create
		ServiceProviderObj, created = ServiceProvider.objects.get_or_create(provider_name = row[1])
		
		EffortInstanceObj.service_provider = ServiceProvider.objects.get(provider_name=row[1])
		
		EffortInstanceObj.updated_on = utc_datetime
		
		EffortInstanceObj.updated_by = 'MSPP scrape'
		
		EffortInstanceObj.save()
		
		loc = Location()
		
		#print 'About to convert this lat string to float: '+row[15]
		if(row[15] and row[15] is not '' and row[15] is not ' '):
			latVal = re.sub(r"\D-", "", row[15]).strip()
			print "latVal is "+latVal
			loc.latitude = latVal

		#print 'About to convert this long string to float: '+row[16]
		if(row[16] and row[16] is not '' and row[16] is not ' '):
			longVal = re.sub(r"\D-", "", row[16]).strip()
			print "longval is "+longVal
			loc.longitude = longVal
			
		if loc.latitude and loc.longitude:
			loc.save(EffortInstanceObj.effort_instance_id)
示例#2
0
        #cool way to make Service Providers unique, if obj does not exist then it creates it.
        #https://docs.djangoproject.com/en/1.6/ref/models/querysets/#get-or-create
        ServiceProviderObj, created = ServiceProvider.objects.get_or_create(
            provider_name=row[1])

        EffortInstanceObj.service_provider = ServiceProvider.objects.get(
            provider_name=row[1])

        EffortInstanceObj.updated_on = utc_datetime

        EffortInstanceObj.updated_by = 'MSPP scrape'

        EffortInstanceObj.save()

        loc = Location()

        #print 'About to convert this lat string to float: '+row[15]
        if (row[15] and row[15] is not '' and row[15] is not ' '):
            latVal = re.sub(r"\D-", "", row[15]).strip()
            print "latVal is " + latVal
            loc.latitude = latVal

        #print 'About to convert this long string to float: '+row[16]
        if (row[16] and row[16] is not '' and row[16] is not ' '):
            longVal = re.sub(r"\D-", "", row[16]).strip()
            print "longval is " + longVal
            loc.longitude = longVal

        if loc.latitude and loc.longitude:
            loc.save(EffortInstanceObj.effort_instance_id)
示例#3
0
			EffortInstanceObj.provider_type = 'CL'
			print 'clinic recorded'
		'''
		
		
		#cool way to make Service Providers unique, if obj does not exist then it creates it.
		#https://docs.djangoproject.com/en/1.6/ref/models/querysets/#get-or-create
		ServiceProviderObj, created = ServiceProvider.objects.get_or_create(provider_name = row[1])
		
		EffortInstanceObj.service_provider = ServiceProvider.objects.get(provider_name=row[1])
		
		EffortInstanceObj.updated_on = utc_datetime
		
		EffortInstanceObj.updated_by = 'MSPP scrape'
		
		loc = Location()

		#having problems with the location strings, must be special non-ASCII characters. ex.
		
		print row[17]
		
		print row[18]
		
		#need to save here so start and end dates are saved to the custom location save can create a new tuple for location_w_efforts table
		EffortInstanceObj.save()
		
		if(len(row[17]) > 1 and not '\\' in row[17] and '.' in row[17]):
			if(len(row[18]) > 1 and not '\\' in row[18] and '.' in row[18]):
		
					loc.latitude = row[17].decode('ascii','ignore').replace(" ", "")
					#loc.latitude = '18.305755'