def process_locs_inputs(wb_name): locs = [] input_wb = xl.load_workbook(filename=wb_name) input_wb_main_ws = input_wb.active state = ["error", "error", "NSW", "VIC", "QLD", "SA", "WA", "TAS", "NT"] print(input_wb_main_ws.max_row) for i in range(2, input_wb_main_ws.max_row + 1): loc = Location() if input_wb_main_ws.cell(row=i, column=1).value == None: loc.loc_ID = i - 1 else: loc.loc_ID = str(input_wb_main_ws.cell(row=i, column=1).value) loc.address = str(input_wb_main_ws.cell(row=i, column=2).value) loc.postcode = str(input_wb_main_ws.cell(row=i, column=3).value) #add co ordinates from bing maps if needed if input_wb_main_ws.cell( row=i, column=4).value == None or input_wb_main_ws.cell( row=i, column=5).value == None: if loc.address == "None": continue print("please provide address or lat/long") loc.get_coordinates() input_wb_main_ws.cell(row=i, column=4).value = loc.lat input_wb_main_ws.cell(row=i, column=5).value = loc.long else: loc.lat = float(input_wb_main_ws.cell(row=i, column=4).value) loc.long = float(input_wb_main_ws.cell(row=i, column=5).value) #add address from bing maps if needed if loc.address == "None": print(i) print(loc.address) loc.get_address() input_wb_main_ws.cell(row=i, column=2).value = loc.address loc.SAM_ID = str(input_wb_main_ws.cell(row=i, column=6).value) loc.status = str(input_wb_main_ws.cell(row=i, column=8).value) loc.MRQ = str(input_wb_main_ws.cell(row=i, column=7).value) if loc.SAM_ID != "None": loc.state = state[int(loc.SAM_ID[0])] else: loc.state = "None" loc.ID = i - 1 dup = False for loc_base in locs: if loc_base.loc_ID == loc.loc_ID: dup = True break if dup == False: locs.append(loc) #wb_name[-5]="1" #print("input saving as: " + wb_name) #input_wb.save(wb_name) input_wb.close() return locs