I have some code that saves a json file and prints it to screen. I am trying to find the best way to iterate through a directory of files, printing one file after another, but I am receiving an '[Errno 13] Permission Denied' error.
At present I am doing the following:
json_path = 'MYPATH'
json_files = [f for f in os.listdir(json_path) if f.endswith('.json')]
for jf in json_files:
with open (os.path.join(json_path)) as my_jf:
json_text = json.load(my_jf)
print(json_text)
I have made sure that the folder in the path is not opened elsewhere, and I have access to it. If there is a simpler way to achieve this I would appreciate the input.