Newer
Older
web-dumps / wos-dumps / 03.3-enrich-Countries.ini
# 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/tablePaysIso2&3.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("WosCountries")
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/assign]
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').split(";").thru(arr => ({ pays: arr[0] || "Unknown", iso2: arr[1] || "Unknown", iso3: arr[2] || "Unknown" }))