Skip to content

Commit

Permalink
Add test if files size is > 0 before copy file (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
dr0i committed Oct 5, 2023
1 parent 1f3ab0a commit fe12013
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion getWikidataLookupTableViaSparql.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# see #482

OUTPUT_FILE="./conf/wikidataLookup.tsv"
OUTPUT_FILE_TMP=${OUTPUT_FILE}".tmp"

# Items that have an ISIL or DBS ID, add GND ID if existing
curl --header "Accept: text/tab-separated-values" -G 'https://query.wikidata.org/sparql' --data-urlencode query='
SELECT ?item ?itemLabel ?isil ?gndId ?dbsId
Expand All @@ -9,4 +14,9 @@ WHERE
OPTIONAL { ?item wdt:P227 ?gndId . } # Add GND ID if in Wikidata.
SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en". }
}
' |sed 's#<##g' | sed 's#^"##g'|sed 's#"\t<#\t#g'|sed 's#>\t"#\t#g' |sed 's#"@..#\t#g' |sed 's#\t"#\t#g' |sed 's#"\t#\t#g' |sed 's#"\^\^.*##g' |sed 's#\t\t#\t#g' |sed 's#"$##g' > ./conf/wikidataLookup.tsv
' |sed 's#<##g' | sed 's#^"##g'|sed 's#"\t<#\t#g'|sed 's#>\t"#\t#g' |sed 's#"@..#\t#g' |sed 's#\t"#\t#g' |sed 's#"\t#\t#g' |sed 's#"\^\^.*##g' |sed 's#\t\t#\t#g' |sed 's#"$##g' > $OUTPUT_FILE_TMP

if [ -s $OUTPUT_FILE_TMP ]; then
mv $OUTPUT_FILE_TMP $OUTPUT_FILE
fi

0 comments on commit fe12013

Please sign in to comment.