I'm looping through many folders to get any JSON file in each folder using the following code:
def get_all_jobs():
for root_dir, _, file_names in os.walk(r'path'):
for file_name in file_names:
if file_name.endswith('.json'):
all_files = (f'{root_dir}/{file_name}')
for file in all_files:
with open(file_name, 'r', encoding="utf8") as json_file:
read_content = json.loads(json_file.read())
and I get this error :
FileNotFoundError: [Errno 2] No such file or directory:
and don't have one path to one folder to give but I have many folders in which I have the files. How can I solve this?