merge json

parent 7147e03b
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
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):
if len(sys.argv) != 2: if len(sys.argv) != 2:
...@@ -15,13 +16,15 @@ def main(argv): ...@@ -15,13 +16,15 @@ 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__":
main(sys.argv) main(sys.argv)
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