from xxlimited import new 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 db from firebase_admin import messaging import threading import xlsxwriter import numpy as np import os from numba import jit, cuda cred = credentials.Certificate('servicekey.json') try: firebase_admin.initialize_app(cred, {'databaseURL': 'https://farmbase-b2f7e-31c0c.firebaseio.com/'}) except: print('fire running') kmlfarms = 'Downloads/set5.xlsx' workbook_kmlfarms = xlrd.open_workbook(kmlfarms) sheet_kmlfarms = workbook_kmlfarms.sheet_by_index(0) tempArr = [1665459417544,1665459583657,1665459688163,1665461530259,1665462092551,1665462658062,1665466415861,1665467351649,1665487208258,1665545959468,1665645533625,1665647043884,1665459417544,1665459583657,1665459688163,1665461530259,1665462092551,1665462658062,1665466415861,1665467351649,1665487208258,1665545959468,1665645533625,16656470438841649902372841,1649902372841,1649902372841,1649903901819,1649901944016,1649908107100,1649908107100,1649951808828,1649906052110,1649904054549,1649879437515,1649879437515,1663217876151,1663239304077,1663242262955,1663297135026,1663298702044,1663299760012,1663305563820,1663326099069,1663383784205,1663383982427,1663385040275,1663385606761,1663386051757,1663386255242,1663387122143,1663387351927,1663388405792,1663391189232,1663391813613,1663391981529,1663472701433,1663477178510,1663480534350,1663481858352,1663486179920,1663486626537,1663491475693,1663491521132,1663491557943,1663559405013,1663561801804,1663564844992,1663565585528,1663565876047,1663575562915,1663577295853,1663579290004,1663588152684,1663590722992,1663591797009,1663646351761,1663646496280,1663646680866,1663647350961,1663647495624,1663647553141,1663648400269,1663648442817,1663648516986,1663648732081,1663649864803,1663650094892,1663651964100,1663653574811,1663654852541,1663655671283,1663656435663,1663656574199,1663656904199,1663657139629,1663658771056,1663659221653,1663660294949,1663660898712,1663666502573,1663671161259,1663671836418,1663672496173,1663672688077,1663672861452,1663673678327,1663674580521,1663675121881,1663675310933,1663675630110,1663675680055,1663675704471,1663728750493,1663730615361,1663730924517,1663731739118,1663732017914,1663734712185,1663734931523,1663735740656,1663736658904,1663739706403,1663741483364,1663742637730,1663745684244,1663747087580,1663751526793,1663754917995,1663756721335,1663757819268,1663758662255,1663758870321,1663759179962,1663759656565,1663759820922,1663759959406,1663762333510,1663763250260,1663812587172,1663813720003,1663814824157,1663815795110,1663816473440,1663817719005,1663820403242,1663820736132,1663821446213,1663831464653,1663843103612,1663845209601,1663845894236,1663847823692,1663848666069,1663849050645,1663903355950,1663903624526,1663903710819,1663904047649,1663906130694,1663909960949,1663911099446,1663914736196,1663916526900,1663919400734,1663919471423,1663925635646,1663928503737,1663933613785,1663935563300,1663935787746,1663936938637,1663937120763,1663937190929,1663988888364,1663990319502,1663990762913,1663991243326,1663991985725,1663992557282,1663992862568,1663994372326,1663994851783,1663996233864,1663997328219,1663997947693,1664000515018,1664001868554,1664002070881,1664002208743,1664004015077,1664004227382,1664006298115,1664008479024,1664015197160,1664018276896,1664161594105,1664161795702,1664177002251,1664177868960,1664178023949,1664188245218,1664193706631,1664246033210,1664250505298,1664250649863,1664250713847,1664250921805,1664258228314,1664280940200,1664333318406,1664339151058,1664341135860,1664765178318,1664775938062,1664849904371,1664851937371,1664853821988,1664854434201,1664856332701,1664857800210,1664880326161,1665031445922,1665114115621,1665117949305,1665120281745,1665122264278,1665137069471,1665198607168,1665199499892,1665373085362,1665373356204,1665374374224,1665375675706,1665375800296,1664422275558,1664422755194,1664422757661,1664422905047,1664423944258,1664428539501,1664431440859,1664521492568,1664523047656,1664524803475,1664525502481,1664540656209,1664593005968,1664006432041] tempArr = [1663217876151,1663239304077,1663242262955,1663297135026,1663298702044,1663299760012,1663305563820,1663326099069,1663383784205,1663383982427,1663385040275,1663385606761,1663386051757,1663386255242,1663387122143,1663387351927,1663388405792,1663391189232,1663391813613,1663391981529,1663472701433,1663477178510,1663480534350,1663481858352,1663486179920,1663486626537,1663491475693,1663491521132,1663491557943,1663559405013,1663561801804,1663564844992,1663565585528,1663565876047,1663575562915,1663577295853,1663579290004,1663588152684,1663590722992,1663591797009,1663646351761,1663646496280,1663646680866,1663647350961,1663647495624,1663647553141,1663648400269,1663648442817,1663648516986,1663648732081,1663649864803,1663650094892,1663651964100,1663653574811,1663654852541,1663655671283,1663656435663,1663656574199,1663656904199,1663657139629,1663658771056,1663659221653,1663660294949,1663660898712,1663666502573,1663671161259,1663671836418,1663672496173,1663672688077,1663672861452,1663673678327,1663674580521,1663675121881,1663675310933,1663675630110,1663675680055,1663675704471,1663728750493,1663730615361,1663730924517,1663731739118,1663732017914,1663734712185,1663734931523,1663735740656,1663736658904,1663739706403,1663741483364,1663742637730,1663745684244,1663747087580,1663751526793,1663754917995,1663756721335,1663757819268,1663758662255,1663758870321,1663759179962,1663759656565,1663759820922,1663759959406,1663762333510,1663763250260,1663812587172,1663813720003,1663814824157,1663815795110,1663816473440,1663817719005,1663820403242,1663820736132,1663821446213,1663831464653,1663843103612,1663845209601,1663845894236,1663847823692,1663848666069,1663849050645,1663903355950,1663903624526,1663903710819,1663904047649,1663906130694,1663909960949,1663911099446,1663914736196,1663916526900,1663919400734,1663919471423,1663925635646,1663928503737,1663933613785,1663935563300,1663935787746,1663936938637,1663937120763,1663937190929,1663988888364,1663990319502,1663990762913,1663991243326,1663991985725,1663992557282,1663992862568,1663994372326,1663994851783,1663996233864,1663997328219,1663997947693,1664000515018,1664001868554,1664002070881,1664002208743,1664004015077,1664004227382,1664006298115,1664008479024,1664015197160,1664018276896,1664161594105,1664161795702,1664177002251,1664177868960,1664178023949,1664188245218,1664193706631,1664246033210,1664250505298,1664250649863,1664250713847,1664250921805,1664258228314,1664280940200,1664333318406,1664339151058,1664341135860,1664422275558,1664422755194,1664422757661,1664422905047,1664423944258,1664428539501,1664431440859,1664521492568,1664523047656,1664524803475,1664525502481,1664540656209,1664593005968,1664006432041,1664765178318,1664775938062,1664849904371,1664851937371,1664853821988,1664854434201,1664856332701,1664857800210,1664880326161,1665031445922,1665114115621,1665117949305,1665120281745,1665122264278,1665137069471,1665198607168,1665199499892,1665373085362,1665373356204,1665374374224,1665375675706,1665375800296,1665459417544,1665459583657,1665459688163,1665461530259,1665462092551,1665462658062,1665466415861,1665467351649,1665487208258,1665545959468,1665645533625,1665647043884,1663217876151,1663239304077,1663242262955,1663297135026,1663298702044,1663305563820,1663326099069,1663386051757,1663386255242,1663387122143,1663388405792,1663391813613,1663391981529,1663472701433,1663477178510,1663480534350,1663481858352,1663486179920,1663491475693,1663564844992,1663565876047,1663575562915,1663577295853,1663588152684,1663591797009,1663646496280,1663647350961,1663647553141,1663648442817,1663649864803,1663650094892,1663653574811,1663654852541,1663655671283,1663656435663,1663657139629,1663658771056,1663660294949,1663660898712,1663666502573,1663672861452,1663728750493,1663730615361,1663730924517,1663731739118,1663734712185,1663735740656,1663742637730,1663745684244,1663747087580,1663758662255,1663758870321,1663763250260,1663813720003,1663814824157,1663815795110,1663816473440,1663817719005,1663820403242,1663820736132,1663831464653,1663903355950,1663903710819,1663904047649,1663911099446,1663916526900,1663919400734,1663928503737,1663935787746,1663988888364,1663990319502,1663992557282,1664000515018,1664002208743,1664006298115,1664250505298,1664280940200,1664333318406,1664339151058,1664341135860,1664422275558,1664422755194,1664422905047,1664423944258,1664428539501,1664431440859,1664765178318,1664854434201,1664856332701,1664857800210,1664880326161,1665114115621,1665120281745,1665122264278,1665137069471,1665198607168,1665199499892,1665373085362,1665373356204,1665374374224,1665375800296,1665461530259,1665462092551,1665462658062,1665466415861,1665487208258] tempArr = [1663217876151,1663239304077,1663242262955,1663297135026,1663298702044,1663305563820,1663326099069,1663386051757,1663386255242,1663387122143,1663388405792,1663391813613,1663391981529,1663472701433,1663477178510,1663480534350,1663481858352,1663486179920,1663491475693,1663564844992,1663565876047,1663575562915,1663577295853,1663588152684,1663591797009,1663646496280,1663647350961,1663647553141,1663648442817,1663649864803,1663650094892,1663653574811,1663654852541,1663655671283,1663656435663,1663657139629,1663658771056,1663660294949,1663660898712,1663666502573,1663672861452,1663728750493,1663730615361,1663730924517,1663731739118,1663734712185,1663735740656,1663742637730,1663745684244,1663747087580,1663758662255,1663758870321,1663763250260,1663813720003,1663814824157,1663815795110,1663816473440,1663817719005,1663820403242,1663820736132,1663831464653,1663903355950,1663903710819,1663904047649,1663911099446,1663916526900,1663919400734,1663928503737,1663935787746,1663988888364,1663990319502,1663992557282,1664000515018,1664002208743,1664006298115,1664250505298,1664280940200,1664333318406,1664339151058,1664341135860,1664422275558,1664422755194,1664422905047,1664423944258,1664428539501,1664431440859,1664765178318,1664854434201,1664856332701,1664857800210,1664880326161,1665114115621,1665120281745,1665122264278,1665137069471,1665198607168,1665199499892,1665373085362,1665373356204,1665374374224,1665375800296,1665461530259,1665462092551,1665462658062,1665466415861,1665487208258] workbook = xlsxwriter.Workbook('new_data2.xlsx') worksheet = workbook.add_worksheet() num = 0 for i in range(0,sheet_kmlfarms.nrows): polygonid = sheet_kmlfarms.cell_value(i,28) polygonid = str(polygonid) fieldid = db.reference('PaidPolygonsByPolygonID').child('PMF').child(polygonid).child('fieldID').get() s_date = sheet_kmlfarms.cell_value(i,0) if i == 0: for k in range(0,28): worksheet.write(num,k,sheet_kmlfarms.cell_value(i,k)) #print(polygonid) else: for k in range(0,28): worksheet.write(num,k,sheet_kmlfarms.cell_value(i,k)) worksheet.write(num,27,sheet_kmlfarms.cell_value(i,k)) num = num+1 print(num) workbook.close()