Skip to content

Commit

Permalink
citation count by id script: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanhb committed Dec 12, 2023
1 parent 7caa2a7 commit e176f82
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions scripts/citation_count_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,26 @@
parser.add_argument('--out', default='citation_count.csv', help='Path to the output CSV file (default: citation_count.csv)')
args = parser.parse_args()

wanted_id = args.id

omid_map = dict()
with open(args.omid, mode='r') as input_csvfile:
reader = csv.reader(input_csvfile)
for row in reader:
if len(row) == 2:
for any_id in row[1].split(" "):
if any_id.startswith(args.id):
if any_id.startswith(wanted_id):
omid = row[0].replace("omid:","")
any_id = any_id.replace("doi:","")
omid_map[omid] = any_id

c = 5
for a in omid_map:
print(a,omid_map[a])
c = c -1
if c == 0:
break


citation_count_by_id = dict()
# Open the input and output CSV files
Expand All @@ -32,9 +41,16 @@
any_id = omid_map[omid]
citation_count_by_id[any_id] = row[1]

c = 5
for a in citation_count_by_id:
print(a,citation_count_by_id[a])
c = c -1
if c == 0:
break

with open(args.out, mode='w', newline='') as output_csvfile:
writer = csv.writer(output_csvfile)
writer.writerow(['id', 'citation_count'])
writer.writerow([wanted_id, 'citation_count'])
for cited in citation_count_by_id:
writer.writerow([cited,str(citation_count_by_id[cited])])

Expand Down

0 comments on commit e176f82

Please sign in to comment.