Sorry if it is at all confusing I am very new to python and am trying to get my foot into the industry by automating simple tasks at the company I work for. This is a for loop designed to pull a specifically labeled page out of a pdf page matching the file path. Everything works fine until the code loops more than twice it gets stuck on the second file, it opens and re runs the second for loop over again instead of iterating again through the first and grabbing the third pdf file. It seems like regardless of the number of loops it gets stuck on the second one. Any help would be greatly appreciated. (the print functions were purely for troubleshooting)
cert_location = 'G:\Materials Received\CERTS SENT\Leave_Empty_Cert_Puller\\'
filepath = df["filename"].tolist()
heatnumber= df["HeatNumber"].tolist()
certname = df["Job"].tolist()
job = str(len(heatnumber))
print(filepath)
print(heatnumber)
print(certname)
i=0
for row in certname:
doc=fitz.open(filepath[i])
page_number = 0
j=0
for Page in doc:
page_name = Page.get_label()
page = doc.load_page(j)
pix = page.get_pixmap()
if page_name == heatnumber[i]:
pix.save(cert_location certname[i] " Heat " heatnumber[i] ".png")
print("we got one")
print(Page)
print ("missed it")
j = 1
print(row)
print("next Job")
i= 1
CodePudding user response:
Its definitely the typo at the end when incrementing 'i' for the outer loop
i = 1
and not
i= 1