Last active
April 16, 2019 20:11
-
-
Save pigreco/95c1e3cfb04c19db10414d8ea428db36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#set -x | |
# estraggo i dati dal file qml | |
<tema.qml xmlstarlet fo -D | xmlstarlet sel -T -t -m "//symbols/symbol" -v $'concat(@name,"\t",layer/prop[@k="color"]/@v)' -n >./idColori.tsv | |
<tema.qml xmlstarlet fo -D | xmlstarlet sel -T -t -m "//category" -v $'concat(@symbol,"\t",@value)' -n >./idRegioni.tsv | |
# metto in JOIN le due tabelle estratte | |
mlr --tsv --implicit-csv-header --headerless-csv-output join -j 1 --lp colori --rp regioni -f idColori.tsv idRegioni.tsv >./out_regioni_xpath.tsv | |
# trasformo il file da csv a tsv | |
mlr --icsv --onidx --ofs "\t" cat layer.csv >layer_t.tsv | |
# metto in JOIN la tabella precedente con il file tsv del layer | |
mlr --nidx --fs "\t" join -j 3 -r 1 --rp r -f out_regioni_xpath.tsv then cut -f 1,r2 layer_t.tsv >out.tsv | |
# sostituisco i valori rgba con quelli che mi interessano tramite file tsv del layer in JOIN | |
while IFS=$'\t' read -r col1 col2 | |
do | |
xmlstarlet ed --inplace -u '//symbols/symbol[@name='"$col1"']/layer/prop[@k="color"]/@v' -v "$col2" tema.qml | |
done < out.tsv | |
# rimuovo i file che non mi servono piu' | |
rm idColori.tsv | |
rm idRegioni.tsv | |
rm out_regioni_xpath.tsv | |
rm layer_t.tsv | |
rm out.tsv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment