Created
March 16, 2017 13:56
-
-
Save samehkamaleldin/a6d9b67fcbdb2785027c1e707bffd2aa to your computer and use it in GitHub Desktop.
Combin 2 json files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
# from tqdm import tqdm | |
link_json_fd = open('link.json') | |
nolink_json_fd = open('nolink.json') | |
link_json = json.load(link_json_fd) | |
nolink_json = json.load(nolink_json_fd) | |
link_json = [ | |
{"title": v["title"], "url": v["doc - url"], "abstract": v["abstract"][0:20]} | |
for v in link_json] | |
result_abstract_list = [] | |
#for a in tqdm(nolink_json): | |
for a in nolink_json: | |
abstract_segment = a["ORIGINAL_ABSTRACT"][0:20] | |
for another_abstract in link_json: | |
if abstract_segment == another_abstract["abstract"]: | |
a["url"] = another_abstract["url"] | |
a["title"] = another_abstract["title"] | |
result_abstract_list.append(a) | |
break | |
result_fd = open("full_link.json", "w") | |
json.dump(result_abstract_list, ensure_ascii=False, fp=result_fd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment