forked from CannonLock/institution_investigation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ror.py
26 lines (20 loc) · 748 Bytes
/
ror.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import requests
import pandas as pd
session = requests.session()
def search_ror(row):
response = session.get("https://api.ror.org/organizations", params={"query": row['Institution Name']})
if response.status_code == 200:
d = response.json()
for i, item in enumerate(d['items']):
if i == 3:
continue
row[f"Name_{str(i).zfill(2)}"] = item['name']
row[f"ID_{str(i).zfill(2)}"] = item['id']
else:
row['Name_00'] = "None"
row['ID_00'] = "None"
return row
if __name__ == "__main__":
df = pd.read_json("data/2023-09-12-final_w_supplemental.json")
df = df.apply(lambda x: search_ror(x), axis=1)
df.to_excel("ror_search.xlsx", index=False)