I am trying to open all the '*.json' files in a directory and get some data out of them
import json
import os #os module imported here
import glob
path = 'C:\Saba\Python Workspace'
for filename in os.listdir(path):
if filename.endswith('.json'):
with open(filename,'r') as f:
data = json.load(filename)
print(data['key'],end="*")
for path in data['paths']:
print(path['method'],end="*")
for resources in path['resources']:
print(resources['key'],end="*")
print("\b"+"$")
This is the Error i get :
Traceback (most recent call last):
File "c:/Saba/Python Workspace/folder.py", line 9, in <module>
with open(filename,'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'order-securityTransferOrders-service-v1.0.0-inventory.json'