In [1]:
library(jsonlite)
library(dplyr)
library(stringr)
library(httr)
# library(rjson)
library(tidyr)
library(psych)
library(reshape)


Attaching package: ‘dplyr’

The following objects are masked from ‘package:stats’:

    filter, lag

The following objects are masked from ‘package:base’:

    intersect, setdiff, setequal, union


Attaching package: ‘reshape’

The following objects are masked from ‘package:tidyr’:

    expand, smiths

The following object is masked from ‘package:dplyr’:

    rename


In [13]:
MyData <- read.csv(file="../data/clients.json", header=TRUE, sep=",")
head(MyData)


idtitlecount
fao.itpgrfa null 33584
dk.gbif Global Biodiversity Information Facility 426
ethz.e-manus e-manuscripta 418
osti.dotntl null 397
spbpu.o-kratkoe null 333
crui.unile Università del Salento 211

In [15]:
get_email <-function(id){
    client<-fromJSON(paste0('https://api.datacite.org/clients/',id))
    return(client$data$attributes$`contact-email`)
}
print(get_email("datacite.datacite"))


[1] "support@datacite.org"

In [22]:
get_total <-function(id){
    client<-fromJSON(paste0('https://api.datacite.org/dois?client-id=',id,'&page[size]=1'))
    created<-client$meta$created
    print(created)
    return("lol")
}
print(get_total("dk.gbif"))


NULL
[1] "lol"

In [17]:
clients <- MyData %>% rowwise() %>% mutate(email=get_email(id))

In [20]:
file<-paste0("../data/",Sys.Date(),"_sclient_list.csv")
print(file)
write.csv(clients,file=file)


[1] "../data/2018-10-25_sclient_list.csv"

In [ ]: