import pandas as pd from collections import defaultdict from itertools import zip_longest from tempfile import tempdir import firebase_admin from firebase_admin import credentials from firebase_admin import db from find_s1_image import find_img_value import pandas as pd from sklearn.metrics import classification_report, confusion_matrix, accuracy_score import statsmodels.api as sm import seaborn as sns sns.set() from zipfile import ZipFile from sklearn.ensemble import RandomForestRegressor from sklearn.model_selection import train_test_split import csv import time import json from find_modis_ndvi import find_modis_ndvi import numpy as np from sklearn.cluster import KMeans from find_study_area_values import find_study_area_values from find_study_area_values3 import find_study_area_values3 from make_area_estimate_image import make_area_estimate_image from make_egypt_estimate_image import make_egypt_estimate_image from sentinelhub import WebFeatureService, BBox, CRS, MimeType, CRS, BBox, WmsRequest,DataCollection import traceback from firebase_admin import firestore from PIL import Image import numpy as np from google.cloud import storage import os from firebase_admin import db from get_mask import get_mask import cv2 import scipy.ndimage from google.oauth2 import service_account import datetime from datetime import date from get_polygon_mask import get_polygon_mask import requests import traceback from ftplib import FTP import paramiko import pysftp import math storage_client = storage.Client.from_service_account_json("servicekey.json"); bucket_name = 'farmbase-b2f7e.appspot.com' cred = service_account.Credentials.from_service_account_file('servicekey.json') #cred = credentials.Certificate('servicekey.json') bucket = storage_client.bucket(bucket_name) try: firebase_admin.initialize_app(credentials.Certificate('servicekey.json'), {'databaseURL': 'https://farmbase-b2f7e-31c0c.firebaseio.com/'}) except: print('fire running') # Read the Excel file df = pd.read_excel("Downloads/trst.xlsx") print(df.columns) # Access the strings stored in the B column strings = df['textPayload'] # Initialize a defaultdict to store counts counts = defaultdict(int) # Count occurrences of each string # for string in strings: # counts[string] += 1 for string in strings: key = string.split('/')[1] counts[key] += 1 # Print counts field_count = 0 total_area = 0 uid = 'D4xU2QGhooXfK6qiEeHdAlp0wk53' for string, count in counts.items(): #print(f"{string}: {count}") field_area = db.reference("PaidMonitoredFields").child("PMF").child(uid).child(string).child("FieldArea").get() total_area = total_area + field_area field_count = field_count + 1 #print(field_area, total_area) print(field_count, total_area)