I am using a while loop with if elif & else. however, it's not breaking out of first loop. I feel I am not putting break at the right place. Any suggestions?
import requests
import pandas as pd
import csv
import sys
import ctypes
import numpy as np
from time import sleep
while True:
Answer = 'yes'
#Answer = input("Are you using an API key? Yes/No ").lower()
if Answer == 'yes':
# API = input("Please enter the API key.")
# SD = input('Please enter the start date')
# ED = input('Please enter the end date within 10 days of range')
API = "apikey"
SD = "2022-09-12"
ED = "2022-09-21"
FilePath = open("ConfigFiles2.csv")
CSV_File = csv.reader(FilePath)
#CSV_File.next()
header = next(CSV_File)
#for row in (CSV_File, unit='Center', desc='Loading'):
for row in CSV_File:
#sleep(0.001)
CID = row[0]
CenterName = row[1]
try:
url = testurl
url2 = testurl2
payload={}
payload2={}
headers = {'Authorization': f"{API}"}
response = requests.request("GET", url, headers=headers, data=payload)
response2 = requests.request("GET", url2, headers=headers, data=payload2)
BlockoutJson = response.json()
Scheduledata = response2.json()
#print (BlockoutJson)
#print (Schedule)
for i in BlockoutJson['block_out_times']:
print(i['employee']['id'], end = ",")
for i in (Scheduledata['employee_schedules']):
sleep(0.001)
dst = i['schedules']
for d in dst:
final = d['shifts']
for g in final:
print(i['employee_id'], end = ',')
print(i['employee_name'], end = ',')
print('Schedule', end = ',')
print(g['start_time'], end = ',')
print(g['end_time'], end = ',')
print(CenterName)
break
except Exception as e:
print(e)
Though I am giving break at the end of the loop, however, it's not breaking.