I tried to call a function in the other function but it is returning an error.
class Data_Wrangling:
def __init__(self):
self.ClassName = type(self).__name__ + '.'
self.Host = None
self.App_Id = None
self.App_Secret = None
self.PySpace = None
def Data_Retrieve(self,URL):
print('\n<> ' + inspect.currentframe().f_code.co_name)
JsonData = None
ST = time.time()
while JsonData is None:
try:
Response = requests.get(URL)
except Exception as E:
print('\n>> Failed: ' + str(E))
if (time.time() - ST)/60 > 1:
print('\n>> Failed: NO valid JsonData Retrieved - Source Down or Internet Issue, etc')
break
JsonData = None
continue
if Response.status_code == 200:
try:
JsonData = json.loads(Response.content.decode('utf-8'))
except Exception as E:
print('\n>> Failed: ' + str(E))
JsonData = None
continue
KN.TPE(ST)
return JsonData
def Processing(self, DatasetId):
Start_Date = '1900-01'
today = datetime.today()
End_Range = str(today.year)+ '-' + str(today.month)
Limit = 5000
Page = 1
URL_Part1 = 'https://maps.clb.org.hk/map/pageList?keyword=&startDate='
URL_Part2 = '&endDate='
URL_Part3 = '&address=&industry=&parentIndustry=&industryName=&accidentType=&accidentTypeName=&companyOwnership=&companyOwnershipName=&deathsNumber=&deathsNumberName=&injuriesNumber=&injuriesNumberName=&mapType=2&page='
URL_Part4 = '&limit='
URL = URL_Part1 + Start_Date + URL_Part2 + End_Range + URL_Part3 + str(Page) + URL_Part4 + str(Limit)
JsonData = Data_Retrieve(URL)
DW = Data_Wrangling()
Export_FilePath = DW.Processing('dtihwnb')
I receive error as:
JsonData = Data_Retrieve(URL)
NameError: name 'Data_Retrieve' is not defined
I am stuck here, thinking what is the issue that I have made here. Please help I am calling Data_Retrieve in Processing.