merge json

parent 7147e03b
...@@ -4,8 +4,9 @@ ...@@ -4,8 +4,9 @@
import sys, os import sys, os
import json import json
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
#def mergeL2ASCL_JSON(jsonList): def mergeL2ASCL_JSON(jsonList):
newDict = dict()
return {i['date']: i for i in jsonList}
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
def main(argv): def main(argv):
...@@ -15,12 +16,14 @@ def main(argv): ...@@ -15,12 +16,14 @@ def main(argv):
dirList = os.listdir(argv[1]) dirList = os.listdir(argv[1])
jsonList = list() jsonList = list()
for f in dirList: for f in dirList:
print(f) # print(f)
with open(argv[1]+f) as ff: with open(argv[1]+f) as ff:
json_data = json.load(ff) json_data = json.load(ff)
json_data['date']=f[:f.find("_")] json_data['date']=f[:f.find("_")]
print(json_data) jsonList.append(json_data)
# print(json_data)
print(json.dumps({i['date']: i for i in jsonList}))
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
if __name__ == "__main__": if __name__ == "__main__":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment