Printing exception reasion. Updated path. Fixed issue with output file name. Added script to check if the PDF exists and adds it to a list if it doesn't.

This commit is contained in:
Dan Dembinski
2021-05-06 11:58:48 -04:00
parent fd4ac10a90
commit 7760bda583
2 changed files with 35 additions and 4 deletions

30
filecheck.py Normal file
View File

@@ -0,0 +1,30 @@
import os
from openpyxl import load_workbook
path = 'U:\\ICP STUFF\\PDF\\'
wb = load_workbook('Missing.xlsx')
sh1 = wb.get_sheet_by_name('Assets')
sh2 = wb.get_sheet_by_name('Missing')
failedrow = 2
for row in sh1.iter_rows(min_row=2):
itemNumber = row[0].value
title = row[1].value
file = path+str(itemNumber)+'.pdf'
print(row[0].value)
# Gets PDF info, splits the 'Page size' key by the space and sets the width and height values
if os.path.exists(file):
# print(file)
pass
else:
print('%s - %s missing' % (str(itemNumber), title))
sh2.cell(row=failedrow, column=1).value = itemNumber
sh2.cell(row=failedrow, column=2).value = title
failedrow = failedrow + 1
wb.save('Missing.xlsx')