def _row_to_request(self, row): request = Request() request.id = row[0] request.kind_premises = row[1] request.post_code = row[2] request.region = row[3] request.city_type = row[4] request.city = row[5] request.street_type = row[6] request.street = row[7] request.house = row[8] request.block = row[9] request.flat = row[10] request.adress = row[11] request.try_num = row[12] return request
def xslx_to_db(): wb = load_workbook(filename=cfg.request_xls_file_path) sheet_ranges = wb.get_active_sheet() i = 2 next_str = sheet_ranges[i] while next_str[0].value: r = Request() r.kind_premises = next_str[0].value r.post_code = next_str[1].value r.region = next_str[2].value r.city_type = next_str[3].value r.city = next_str[4].value r.street_type = next_str[5].value r.street = next_str[6].value r.house = next_str[7].value r.block = next_str[8].value r.flat = next_str[9].value r.adress = next_str[10].value db = DB() db.insert(r, 'request') i += 1 next_str = sheet_ranges[i]