-
Notifications
You must be signed in to change notification settings - Fork 0
/
draft.py
27 lines (24 loc) · 901 Bytes
/
draft.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
import json
import glob
import os
def json_merge(fold_path,input_base,output_base,Max_mem):
count=0
path_in=os.path.join(fold_path, input_base+'*.json')
path_out = os.path.join(fold_path, output_base+str(count)+'.json')
list_files=[]
if glob.glob(path_in,recursive= True):
list_files=glob.glob(path_in,recursive= True)
merge=[]
for file in list_files:
with open(file, 'rb') as infile:
merge.append(json.load(infile))
with open(path_out,'w') as outfile:
json.dump(merge,outfile,indent=2)
info=os.stat(path_out)
if info.st_size > Max_mem:
print("Memory Limit Exceeded")
else:
print("Output file within memory limits")
count=count+1
else:
print("File not found,Enter valid path and base name")