import fiona import requests import utm from geopy.geocoders import Nominatim import time import json import pandas as pd from fastkml import kml import xlrd from statistics import median import math import firebase_admin from firebase_admin import credentials from firebase_admin import firestore from find_s1_image import find_img_value from sentinelhub import WebFeatureService, BBox, CRS, DataSource, MimeType, CRS, BBox, WmsRequest,DataCollection cred = credentials.Certificate('servicekey.json') firebase_admin.initialize_app(cred, {'databaseURL': 'https://farmbase-b2f7e-31c0c.firebaseio.com/'}) db = firestore.client() storesxlsx = 'stores.xlsx' def try_lower(temp_str): try: temp_str = temp_str.lower() except: wew = 1 return temp_str workbook_kmlfarms = xlrd.open_workbook(storesxlsx) sheet_kmlfarms = workbook_kmlfarms.sheet_by_index(0) #print(amro_obj) for i in range(1, sheet_kmlfarms.nrows): try: single_farmer_obj = {} state = sheet_kmlfarms.cell_value(i,0) state = try_lower(state) zone = sheet_kmlfarms.cell_value(i,1) zone = try_lower(zone) #print(farmer_coordinates) amro = sheet_kmlfarms.cell_value(i,2) amro = try_lower(amro) store = sheet_kmlfarms.cell_value(i,3) store = try_lower(store) village = sheet_kmlfarms.cell_value(i,4) village = try_lower(village) single_farmer_obj["zone"] = zone single_farmer_obj["amro"] = amro single_farmer_obj["store"] = store single_farmer_obj["village"] = village single_farmer_obj["district"] = '-' single_farmer_obj["state"] = state db.collection("cities").document("LA").set(single_farmer_obj) except Exception as e: print(e)