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) #EffortInstanceObj.location = Location.objects.get(location_id=loc.location_id) EffortInstanceObj.location = Location.objects.get(id=loc.id) #LocationObj, created = Location.objects.get_or_create(location_id=row[0],latitude = loc.latitude, longitude = loc.longitude)
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) #EffortInstanceObj.location = Location.objects.get(location_id=loc.location_id) EffortInstanceObj.location = Location.objects.get(id=loc.id) #LocationObj, created = Location.objects.get_or_create(location_id=row[0],latitude = loc.latitude, longitude = loc.longitude)
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' loc.longitude = row[18].decode('ascii','ignore').replace(" ", "") #loc.longitude = '-72.172367' loc.save(EffortInstanceObj.effort_instance_id) #LocationObj, created = Location.objects.get_or_create(location_id=row[0],latitude = loc.latitude, longitude = loc.longitude) EffortInstanceObj.location = Location.objects.get(id=loc.id) #Location.objects.get(location_id=loc.location_id) EffortInstanceObj.save()