def endElement(self, name): if name == 'Placemark': truck = FoodTruck(key=self.curr_id, name=self.curr_name, foodType=self.curr_description, position=self.curr_position) truck.save() print "saved: "+ str(truck); self.curr_name = "" self.curr_description = "" self.curr_position = Position(lat=0,lon=0) self.curr_id = 0 self.buff = "" elif name == 'name': self.curr_name = self.buff elif name == 'description': self.curr_description = self.buff elif name == 'coordinates': coords = self.buff.split(",") print "float(coords[0])" + str(coords[0]) + "float(coords[1])" + str(coords[1]) self.curr_position = Position(lat=float(coords[1]), lon=float(coords[0])) self.curr_position.save() self.buff = ""
def saveRowAsTruck(worksheet, row_index): if (isValidTruck(worksheet, row_index)): flat = worksheet.cell_value(row_index, 6) flon = worksheet.cell_value(row_index, 7) floc = worksheet.cell_value(row_index, 4) p = Position(lat=float(flat), lon=float(flon)) p.save() if (worksheet.cell_type(row_index, 3) is not 1): fname = "Food Cart" else: fname = worksheet.cell_value(row_index, 3) if (worksheet.cell_type(row_index, 5) is not 1): fdescription = "Mystery Food" else: fdescription = worksheet.cell_value(row_index, 5) fkey = worksheet.cell_value(row_index, 0) t = FoodTruck(key=fkey, name=fname, foodType=fdescription, position=p, location=floc) t.save()