update20140630
This commit is contained in:
25
uni/masterarbeit/source/scripts/analysis/json/jsonutility.py
Normal file
25
uni/masterarbeit/source/scripts/analysis/json/jsonutility.py
Normal file
@@ -0,0 +1,25 @@
|
||||
__author__ = 'stubbfel'
|
||||
import json
|
||||
import glob
|
||||
|
||||
def readJSON(fileName):
|
||||
with open(fileName, newline='\n') as jsonFile:
|
||||
jsonObject = json.loads(jsonFile.read())
|
||||
return jsonObject
|
||||
|
||||
def writeJSON(fileName, jsonObject):
|
||||
with open(fileName, 'w', newline='\n') as jsonFile:
|
||||
jsonFile.write(json.dumps(jsonObject, indent=4))
|
||||
jsonFile.close()
|
||||
|
||||
def mergeJSON(files, outPutfileName):
|
||||
mergeObject = {}
|
||||
for fileName in files:
|
||||
jsonObject = readJSON(fileName)
|
||||
mergeObject[fileName] = jsonObject
|
||||
writeJSON(outPutfileName, mergeObject)
|
||||
|
||||
#print (glob.glob("*.json"))
|
||||
#result = readJSON("test.json")
|
||||
#writeJSON("boo.json", result)
|
||||
#mergeJSON(["test.json","boo.json"],"bla.json")
|
||||
Reference in New Issue
Block a user