What i’m trying to do is add +1 for each time a function is ran and then use that new number in the function to specify a new field in the .xls document using Pandas. The function i posted below is ran when a button is pressed using tkinter. Currently it only reads row 1 (a2,b2) in the .xls document.
What i want to do is run this function again or loop and every pass +=1
to the number specified as Row
. I know i can use len(fd)
to count how many rows the excel sheet has so i can set it to stop when it hits that number. Any help with this would be great i’ve kinda been stuck on this for a couple days and haven’t really got anywhere.
def Run_bot():
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("http://User.Password@pulse1.pgd.com/Admin")
df = pd.read_excel("designs.xls", usecols=("State", "TemplateName"))
Row = 1
TemplateName = (df.loc[Row, 'State'])
Design = (df.loc[Row, 'TemplateName'])
##Loop from here down
driver.get("http://pulse1.pgd.com/Admin/Designs/Create")
time.sleep(1) # gives time for page to respond
DesName = driver.find_element_by_xpath('//*[@id="Name"]')
FileName = driver.find_element_by_xpath("//*[@id='File_chosen']/a")
FileSearch = driver.find_element_by_xpath(
'//*[@id="File_chosen"]/div/div/input')
CreateBtn = driver.find_element_by_xpath(
"/html/body/div/div[1]/div/form/div/div/input")
DesName.clear()
DesName.send_keys(TemplateName) # Inputs template name
time.sleep(1) # waits 1 second for page to respond
FileName.click() # clicks on search box
FileSearch.send_keys(Design + "\n") # types in Design and hits enter
time.sleep(1) # waits 1 seconds for art to load
CreateBtn.click() # Clicks to create template```