diff --git a/conditor-dumps/04-enrich-rnsrByYear.ini b/conditor-dumps/04-enrich-rnsrByYear.ini new file mode 100644 index 0000000..2ed3442 --- /dev/null +++ b/conditor-dumps/04-enrich-rnsrByYear.ini @@ -0,0 +1,38 @@ +# Création d'une variable d'environnement qui stocke la date au format ISO +[env] +path = date +value = thru(d => (new Date()).toISOString().split("T")[0]) + +# Sert à traiter individuellement chaque valeur de la liste (chaque code ici) +[map] +path = value +# Création d'une clé temporaire pour stocker la valeur actuelle +[map/replace] +path = tmpkey +value = self() + +[map/combine] +path = tmpkey +# URL vers un fichier CSV accessible via internet +primer = http://mapping-tables.daf.intra.inist.fr/rnsr-year-instituts-cnrs.tsv + +# Création d'un fichier temporaire local avec la date définie dans [env] (facultatif, évite de télécharger le fichier plusieurs fois) +cacheName = env("date").prepend("yo") +default = n/a + +[map/combine/URLStream] +path = false + +[map/combine/CSVParse] +separator = fix("\t") + +[map/combine/CSVObject] +# Une fois le TSV parsé en objets JSON, la valeur de "From" est transformé en clé et celle de "To" en valeur ({"From": "code1", "To": "Intitulé1"}). Puis on transforme l'objet avec "intitule" comme clé. +[map/combine/replace] +path = id +value = get('From') +path = value +value = get('To').split().zipObject(["intitule"]).invert() +# Enfin on extrait uniquement la vaeur de "intitule" après le mapping +[map/exchange] +value = get('tmpkey.value.intitule') diff --git a/conditor-dumps/04-enrich.ini b/conditor-dumps/04-enrich.ini index 8f788b9..aa71070 100644 --- a/conditor-dumps/04-enrich.ini +++ b/conditor-dumps/04-enrich.ini @@ -55,12 +55,9 @@ [expand/expand] path = value.institut size = 100 +file = ./04-enrich-rnsrByYear.ini cacheName = fix(`${env('cacheSalt')}-04-rnsr-year-instituts-cnrs`) -[expand/expand/URLConnect] -url = https://mapping-tools.services.istex.fr/v1/rnsr-year/instituts-cnrs -timeout = 90002 -noerror = true [expand/assign] path = value.label