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
1 merge request!3Prise en compte des relations des jeux de données, versions, jeux identiques...
...@@ -63,10 +63,10 @@ if temp_rows : ...@@ -63,10 +63,10 @@ if temp_rows :
if result[0] not in dois_added: if result[0] not in dois_added:
dois_added.append(result[0]) dois_added.append(result[0])
df_fresh.loc[i, "doi"] = result[0] df_fresh.loc[i, "doi"] = result[0]
df_fresh.loc[i, "relation_nbInstances"] = result[1] if str(result[1]) != "[]": df_fresh.loc[i, "traveled_dois"] = str(result[1])
df_fresh.loc[i, "relation_nbCitation"] = result[2] else: df_fresh.loc[i, "traveled_dois"] = ""
if str(result[3]) != "[]": df_fresh.loc[i, "traveled_dois"] = str(result[3]) if str(result[2]) != "[]": df_fresh.loc[i, "all_relations"] = str(result[2])
if str(result[4]) != "[]": df_fresh.loc[i, "all_relations"] = str(result[4]) else: df_fresh.loc[i, "all_relations"] = ""
else: else:
to_del.append(i) to_del.append(i)
......
import requests, json 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 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}" ) req = requests.get( f"https://api.datacite.org/dois/{doi}" )
res = req.json() res = req.json()
final = [] final = []
result = (doi, count, cited, history, final) result = (doi, history, final)
try: try:
related = res["data"]["attributes"]["relatedIdentifiers"] related = res["data"]["attributes"]["relatedIdentifiers"]
except: except:
...@@ -20,14 +19,13 @@ def get_origin_version(doi, count=0, cited=0, history=[], first=True): ...@@ -20,14 +19,13 @@ def get_origin_version(doi, count=0, cited=0, history=[], first=True):
ignore = True ignore = True
elem_to_save_i = i.get("relatedIdentifier") elem_to_save_i = i.get("relatedIdentifier")
history.append([i.get("relationType"), 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": if i.get("relationType") == "IsIdenticalTo" and i.get("relatedIdentifierType") == "DOI":
duplicate = True duplicate = True
elem_to_save_d = i.get("relatedIdentifier") elem_to_save_d = i.get("relatedIdentifier")
history.append([i.get("relationType"), i.get("relatedIdentifier")]) history.append([i.get("relationType"), i.get("relatedIdentifier")])
if duplicate and not(ignore): if duplicate and not(ignore):
result = (elem_to_save_d, count, cited, history, final) result = (elem_to_save_d, history, final)
if ignore: result = get_origin_version(elem_to_save_i, count+1, cited, history, False) if ignore: result = get_origin_version(elem_to_save_i, history, False)
return result return result
def get_md_from_datacite( doi ) : 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