forked from BSCrumpton/ImportFhirJson
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuploadFiles.py
31 lines (27 loc) · 871 Bytes
/
uploadFiles.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os, json
paths=[]
paths.append("/home/bcrumpton3-gtri/Documents/AllOfUs/ImportFhirJson/test")
jsonFiles=[]
for rootdir in paths:
for root, dirs, files in os.walk(rootdir):
for name in files:
if name.endswith((".json")):
print(name)
full_path = os.path.join(root, name)
jsonFiles.append(full_path)
print(jsonFiles)
jsonStrings=[]
for jsonFile in jsonFiles:
with open(jsonFile,'r') as f:
try:
tempString=json.load(f)
jsonStrings.append(tempString)
except json.JSONDecodeError:
print("file {} is invalid json".format(jsonFile))
for jsonString in jsonStrings:
if(jsonString.get('resource',None)):
print("format one")
print(jsonString.get('resource'))
else:
print("format two")
print(jsonString)