Closed hugolpz closed 1 year ago
Suggestion of working JQ based on these 4 files:
jq \
--argjson languagesGenderData "$(<./data/LL-LanguagesGenderData.json)" \
--argjson languagesActive "$(<./data/LL-LanguagesActive.json)" \
--argjson languagesRecordsData "$(<./data/LL-LanguagesRecordsData.json)" \
--argjson languagesPopulationData "$(<./data/WD-LanguagesPopulationData.json)" \
'[ $languagesGenderData + $languagesActive + $languagesRecordsData + $languagesPopulationData | group_by(.wikidata) | .[] | reduce .[] as $obj ({}; . * $obj) ]' <<< "{}" > ./data/languages-all.json
The following was eventually implemented :
jq -s 'add | group_by(.wikidata) | map(add) | map(select(.records > 0)) | sort_by((.records | tonumber) // 0) | reverse' \
./data/LL-LanguagesSpeakersData.json ./data/LL-LanguagesGenderData.json ./data/LL-LanguagesActive.json ./data/LL-LanguagesRecordsData.json ./data/WD-LanguagesPopulationData.json \
> ./data/languages-gallery.json
Given json files :
Join file by common wikidata property if value is equal. Idea :