def uploadData(sheet, email, sheet_name): if sheet_name == "2.BaseData": data = [] headers = [cell.value for cell in sheet[1]] for row in sheet.iter_rows(min_row=2): row_data = { headers[i]: cell.value for i, cell in enumerate(row) if cell.value is not None } if row_data: # Only append if row_data is not empty row_data = trim_dict_spaces(row_data) data.append(row_data) print(data) # If socio_econ_vulnerability_collection expects each row to be uploaded individually for row in data: socio_econ_vulnerability_collection.add(row) return data
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter