Script to dump excel data of socio_econ_vulnerability

PHOTO EMBED

Sat Sep 07 2024 13:09:16 GMT+0000 (Coordinated Universal Time)

Saved by @swadhinpaul #python

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
content_copyCOPY

Script to dump excel data of socio_econ_vulnerability excel to firestore

https://chatgpt.com/c/66d9c7f1-9ff4-8002-9f5c-fa4060f7338e