I am simply trying to add a counter around my for loop, to count how many files are in my directory per qualification of the contains 'VCCS'... the logic is working for the iterating, as it's iterating through my directory the amount of times I have a file in... however my counter keeps reporting 1. Relevant lines are files_in_directory
I've tried moving the set 0, above the for and try, any thoughts?
if __name__ == "__main__":
try:
currentDT = datetime.datetime.now()
files_in_directory = 0 # here
for filename in os.listdir(config.DIRECTORY_LOCATION):
if filename.__contains__('VCCS'):
old_stdout = sys.stdout
log_file = open("./logs/metrics.log","w")
sys.stdout = log_file
files_in_directory += 1 # here
PENDING_RECORDS = FindPendingRecords().get_excel_data()
# Do operations on PENDING_RECORDS
# Reads excel to map data from excel to vital
MAP_DATA = FindPendingRecords().get_mapping_data()
# Configures Driver
VITAL_ENTRY = VitalEntry()
# Start chrome and navigate to vital website
VITAL_ENTRY.instantiate_chrome()
# Begin processing Records
VITAL_ENTRY.process_records(PENDING_RECORDS, MAP_DATA)
print(f"Date: ")
print (str(currentDT))
print(f"Files in Directory #{files_in_directory}")
sys.stdout = old_stdout
log_file.close()
except Exception as exc:
# print(exc)
raise
Aucun commentaire:
Enregistrer un commentaire