mirror of
https://github.com/Priyatham-sai-chand/compara-deep-learning.git
synced 2026-10-05 08:11:34 -07:00
28 lines
665 B
Python
28 lines
665 B
Python
|
|
import os
|
||
|
|
import pickle
|
||
|
|
import json
|
||
|
|
import sys
|
||
|
|
|
||
|
|
def write_dict_json(name,dir,d):
|
||
|
|
if not os.path.exists(dir):
|
||
|
|
os.mkdir(dir)
|
||
|
|
|
||
|
|
path=os.path.join(dir,name+".json")
|
||
|
|
with open(path,'w') as file:
|
||
|
|
json.dump(d,file)
|
||
|
|
|
||
|
|
def write_file_multiple_json(name,dir,l):
|
||
|
|
if not os.path.exists(dir):
|
||
|
|
os.mkdir(dir)
|
||
|
|
|
||
|
|
path=os.path.join(dir,name)
|
||
|
|
with open(path,"w") as file:
|
||
|
|
for x in l:
|
||
|
|
out=json.dumps(x)
|
||
|
|
file.write(out)
|
||
|
|
file.write('\n')
|
||
|
|
|
||
|
|
def save_data_json(name,data):
|
||
|
|
with open(name+".json","w")as file:
|
||
|
|
json.dump(data,file)
|