Skip to content
Snippets Groups Projects
Commit b3c8eea6 authored by Elias Chetouane's avatar Elias Chetouane
Browse files

Suppression des colonnes inutiles.

parent e2e466d5
No related branches found
No related tags found
No related merge requests found
......@@ -63,10 +63,10 @@ if temp_rows :
if result[0] not in dois_added:
dois_added.append(result[0])
df_fresh.loc[i, "doi"] = result[0]
df_fresh.loc[i, "relation_nbInstances"] = result[1]
df_fresh.loc[i, "relation_nbCitation"] = result[2]
if str(result[3]) != "[]": df_fresh.loc[i, "traveled_dois"] = str(result[3])
if str(result[4]) != "[]": df_fresh.loc[i, "all_relations"] = str(result[4])
if str(result[1]) != "[]": df_fresh.loc[i, "traveled_dois"] = str(result[1])
else: df_fresh.loc[i, "traveled_dois"] = ""
if str(result[2]) != "[]": df_fresh.loc[i, "all_relations"] = str(result[2])
else: df_fresh.loc[i, "all_relations"] = ""
else:
to_del.append(i)
......
import requests, json
def get_origin_version(doi, count=0, cited=0, history=[], first=True):
def get_origin_version(doi, history=[], first=True):
if first: history=[] # ligne ajoutée pour éviter certains soucis de cache où history n'est pas vide au premier appel de la fonction
cited = 0
req = requests.get( f"https://api.datacite.org/dois/{doi}" )
res = req.json()
final = []
result = (doi, count, cited, history, final)
result = (doi, history, final)
try:
related = res["data"]["attributes"]["relatedIdentifiers"]
except:
......@@ -20,14 +19,13 @@ def get_origin_version(doi, count=0, cited=0, history=[], first=True):
ignore = True
elem_to_save_i = i.get("relatedIdentifier")
history.append([i.get("relationType"), i.get("relatedIdentifier")])
if i.get("relationType") == "isCitedBy" and i.get("relatedIdentifierType") == "DOI": cited += 1
if i.get("relationType") == "IsIdenticalTo" and i.get("relatedIdentifierType") == "DOI":
duplicate = True
elem_to_save_d = i.get("relatedIdentifier")
history.append([i.get("relationType"), i.get("relatedIdentifier")])
if duplicate and not(ignore):
result = (elem_to_save_d, count, cited, history, final)
if ignore: result = get_origin_version(elem_to_save_i, count+1, cited, history, False)
result = (elem_to_save_d, history, final)
if ignore: result = get_origin_version(elem_to_save_i, history, False)
return result
def get_md_from_datacite( doi ) :
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment