-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NN-617 Extract source code & sequencing data
- Loading branch information
1 parent
50d0d3c
commit a5a580a
Showing
2 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import json | ||
import os | ||
|
||
def format_data(): | ||
"""Publications having Data Availability and Code Availability separate are merged in a single entry""" | ||
|
||
files = [f for f in os.listdir('.') if f.startswith('_') and f.endswith('udc.json')] | ||
|
||
for file in files: | ||
with open(file,'r', encoding="utf-8") as f: | ||
data = json.load(f) | ||
|
||
duplicates = set() | ||
new_data = {} | ||
|
||
for paper in data: | ||
if paper['DOI'] in list(duplicates): | ||
new_data[paper['DOI']]['paragraph'] += "\n"+ paper['paragraph'] | ||
else: | ||
duplicates.add(paper['DOI']) | ||
new_data.update({paper['DOI']:paper}) | ||
|
||
formated_data = [] | ||
for value in new_data.values(): | ||
formated_data.append(value) | ||
with open(f"{file}_formatted.json","w") as f: | ||
json.dump(formated_data, f, indent=4) | ||
|
||
if __name__ == "__main__": | ||
format_data() |
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