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

demo pour atelier rencontre référents données

parent 5bfc1920
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:ce5cebe1-a058-4c0f-a5b5-23a02baa3521 tags:
# Démo récupération des DOIs affiliés à l'UGA depuis Datacite
## Documentation
* Doc générale API Datacite : https://support.datacite.org/docs/api
* Recherche d'un DOI : https://support.datacite.org/docs/api-sampling
* Pagination : https://support.datacite.org/docs/pagination
## Code
%% Cell type:code id:d229201d-4e79-40a8-9472-9ea46b344b1c tags:
``` python
import requests, json, pandas
```
%% Cell type:code id:7ce19b89-d5b7-4dbe-9fab-a15a81b42078 tags:
``` python
# construction de l'url
url_pre = 'https://api.datacite.org/dois?affiliation=true&page[size]=1000'
url_query = '&query=(creators.affiliation.affiliationIdentifier:"https://ror.org/02rx3b187") AND (types.resourceTypeGeneral:Dataset)'
# obtention des résultats de la requête
req = requests.get(url_pre + url_query)
results = req.json()
```
%% Cell type:code id:ec73be41-21df-4448-b58e-e21306f6b9fa tags:
``` python
# ajouter les DOIs dans une liste, sans ajouter les résultats qui ne sont pas des DOIs
# ajouter les autres résultats qui nous intéressent dans des listes afin de construire un DataFrame
dois = []
not_dois = []
titles = []
dates = []
authors = []
# boucler pour ajouter les informations relatives à chaque dépôt
num_dois = results["data"]
nb_dois = len(num_dois)
for item in num_dois :
doi = item["id"]
# si l'identifiant n'est pas un doi, on ne le prend pas
if item.get("type") != "dois":
print("Le résultat " + str(item) + " est de type " + item.get("type") + " : " + doi)
not_dois.append(doi)
# sinon, on récupère les informations dont on a besoin
else:
dois.append(doi)
titles.append(item["attributes"]["titles"][0].get("title"))
dates.append(item["attributes"]["created"])
# boucler pour obtenir tous les auteurs
auts = []
for aut in item["attributes"]["creators"]:
auts.append(aut.get("name"))
authors.append(auts)
# affichage du résultat
print("Nombre de résultats trouvés : " + str(nb_dois))
```
%% Output
Nombre de résultats trouvés : 142
%% Cell type:code id:e0722b5b-0059-4842-8e8a-2125239a7b7d tags:
``` python
# construction du DataFrame
df = pandas.DataFrame({'DOI':dois, 'Titre':titles, 'Date':dates, 'Auteurs':authors})
print(df)
df.to_csv("z-resultats-demo-datacite.csv")
```
%% Output
DOI \
0 10.7280/d11h3x
1 10.7280/d1mm37
2 10.7280/d1595v
3 10.7280/d1667w
4 10.7280/d1b114
.. ...
137 10.6084/m9.figshare.23488967
138 10.18150/wyyjk6
139 10.13127/efsm20
140 10.5285/3ea504d8-41c2-40dc-86dc-284c341badaa
141 10.5285/634ee206-258f-4b47-9237-efff4ef9eedd
Titre Date \
0 Annual Ice Velocity of the Greenland Ice Sheet... 2019-03-29T12:53:36Z
1 Annual Ice Velocity of the Greenland Ice Sheet... 2018-12-14T09:39:45Z
2 Annual Ice Velocity of the Greenland Ice Sheet... 2019-03-29T10:37:23Z
3 Greenland Marine-Terminating Glacier Retreat Data 2020-12-01T18:09:19Z
4 Dataset for: Fast retreat of Pope, Smith, and ... 2021-11-01T23:46:08Z
.. ... ...
137 Additional file 1 of 3DVizSNP: a tool for rapi... 2023-06-10T03:21:52Z
138 Estimates for recombination coefficients from ... 2022-04-21T14:17:28Z
139 European Fault-Source Model 2020 (EFSM20): onl... 2022-10-30T16:28:46Z
140 Ice radar data from Little Dome C, Antarctica,... 2022-03-04T09:26:18Z
141 Polarimetric ApRES data on a profile across Do... 2021-09-16T11:17:15Z
Auteurs
0 [Mouginot, Jeremie, Rignot, Eric, Scheuchl, Be...
1 [Mouginot, Jeremie, Rignot, Eric, Millan, Roma...
2 [Mouginot, Jeremie, Rignot, Eric, Scheuchl, Be...
3 [Wood, Michael, Rignot, Eric, Bjørk, Anders, V...
4 [Milillo, Pietro, Rignot, Eric, Rizzoli, Paola...
.. ...
137 [Sierk, Michael, Ratnayake, Shashikala, Wagle,...
138 [Sakowski, Konrad, Borowik, Lukasz, Rochat, Né...
139 [Basili, Roberto, Danciu, Laurentiu, Beauval, ...
140 [Mulvaney, Robert, King, Edward, Martin, Carlo...
141 [Corr, Hugh, Ritz, Catherine, Martin, Carlos]
[142 rows x 4 columns]
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