User:Itu/script/ingv quake2wikitable.sh


 * 1) you may improve that script


 * 1) https://en.wikipedia.org/wiki/User:Itu/script/ingv_quake2wikitable.sh

echo echo ' This script produces a wikitable out of the data of cnt.rm.ingv.it/en that you get with the  export list > Text  on the right ' echo

# todo: make a request of parameters so the datatable can get downloaded automatically

arg1=$1 ;  if   [ "$arg1" = ""  ] ;  then  read -p 'Textfile with data?: ' arg1  ; fi

datafile=$arg1

echo echo ' ' echo echo '' echo ' ' echo '{| class="wikitable sortable" style="text-align: center;"' echo '! rowspan="2" |Date / local time (UTC) ' echo '! rowspan="2" | Magnitude' echo '! rowspan="2" | Type ' echo '! rowspan="2" | Depth Hypocenter' echo '! colspan="3" | Epicenter' echo '|-' echo '! Location' echo '! Latitude' echo '! Longitude'

while read line do                                                      ### echo -n $((nn++))"  " echo $line | grep -q EventID &&  continue   # skip headline ( trust on the following order ) [ "$line" = "" ] && continue

date=$( echo $line | cut -d'|' -f2 ) latitude=$( echo $line | cut -d'|' -f3 ) longitude=$( echo $line | cut -d'|' -f4 ) depth=$( echo $line | cut -d'|' -f5 ) mag=$( echo $line | cut -d'|' -f11 ) magtype=$( echo $line | cut -d'|' -f10 )

locality=$( echo $line | cut -d'|' -f13 )

if [ $( echo $mag | cut -b1 ) -ge 5  ] ; then echo '|- style="background-color:lightblue"' else echo '|-' fi

echo '|'$( date -d $date  "+%Y-%m-%d    %H:%M :%S " ) echo '|'$mag echo '|'$magtype echo '|'$depth' km' echo '|'$locality'' echo '|'$latitude echo '|'$longitude

done            < $arg1

echo '|}' echo '' echo ' ' echo echo