script pour établir une bdd Ãà partir d'un tsv avec différent format - retour accueil
git clone git://bebou.netlib.re/laradb
Log | Files | Refs |
commit 218b8723da93ec1863aa5cd8cab212e6bdb09c2e parent d765fc6f95e6d24e6b9e0d83e89359ca83f7efc7 Auteurice: vi <vi@bb.re> Date: Sun, 10 Nov 2024 22:09:08 +0100 updated timeline and date_epoch script Diffstat:
M | src/timeline.sh | | | 35 | +++++++++++++++++++---------------- |
M | src/utils/date_epoch.sh | | | 22 | ++++++++++++++++------ |
2 files changed, 35 insertions(+), 22 deletions(-)
diff --git a/src/timeline.sh b/src/timeline.sh @@ -1,12 +1,14 @@ #!/bin/sh -# @todo: la durée ne prend en compte que les années et pas les mois/jour -# tout passer en unix epoch : -# date -j +%s 195509030000 #ccddmmjjHHMM 1955 09 03 00:00 +# @todo: DONE +# - no dist directory in the git repo +# - set up manually start date (min) and end date (max) DONE +# - volumes +# - #./src/utils/date_epoch.sh -echo Building timeline.html +echo Building timeline.html DIST="dist" DB="src/db.tsv" @@ -15,19 +17,20 @@ OUT=$(basename "$0" | sed "s/sh$/html/g") epoch_start="tmp/start_unixepoch" epoch_end="tmp/end_unixepoch" -max=$( sort tmp/end | tail -n1 | grep -o "^.\{4\}" | sed 's/$/ + 1/' | bc ) -min=$( sort tmp/start | head -n1 | grep -o "^.\{4\}") - -#max=2012 -#min=1971 +#max=$( sort tmp/end | tail -n1 | grep -o "^.\{4\}" | sed 's/$/ + 1/' | bc ) +#min=$( sort tmp/start | head -n1 | grep -o "^.\{4\}") +max=1991 +min=1971 echo "max = $max : min = $min" # max = 2012 : min = 1971 - -min_epoch=$( cut -f1 tmp/start_unixepoch | sort -g | head -n1 ) -max_epoch=$( cut -f1 tmp/end_unixepoch | sort -g | tail -n1) +#min_epoch=$( cut -f1 tmp/start_unixepoch | sort -g | head -n1 ) +#max_epoch=$( cut -f1 tmp/end_unixepoch | sort -g | tail -n1) +min_epoch=$(date +%s --date="${min}-01-01" ) +max_epoch=$(date +%s --date="${max}-01-01" ) echo "$min_epoch ; $max_epoch " # 41900400 ; 1304200800 + entree(){ echo "$line" | cut -d" " -f $1 #echo "$line" | tsv-select -f $1 @@ -46,7 +49,7 @@ width(){ } annee(){ #seq $min $max | xargs printf '<td onclick="sortTable(2)" class="annee">%s</td>\n' - seq 1971 $max | xargs printf '<td onclick="sortTable(2)" class="annee">%s</td>\n' + seq $min $max | xargs printf '<td class="annee">%s</td>\n' } LIGNE=1 @@ -59,8 +62,8 @@ $(while IFS= read -r line; do cat <<- ENTETE <thead> <tr> - <!--<td onclick="sortTable(2)" class="titre-complet">$(entree 2; entree 3 )</td>--> - <!--$(annee)--> + <td onclick="sortTable(2)" class="titre-complet">$(entree 2; entree 7 )</td> + $(annee) </tr> </thead> @@ -68,7 +71,7 @@ ENTETE else cat <<- CORPS <tr> - <td class="titre-complet"> $(entree 3)</td> + <td class="titre-complet"> $(entree 2)</td> <td class="rectangle"> <div style="left: $(left)% ; width: $(width)%;"></div> </td> diff --git a/src/utils/date_epoch.sh b/src/utils/date_epoch.sh @@ -31,10 +31,9 @@ s/0000 / /; # in format YYYYMMDD ' #cut -f1 | #xargs -n1 date -j +%s } - clean 5 > tmp/start clean 6 > tmp/end -paste -d "\t" tmp/start tmp/end | tee tmp/dateEpoch_final.tsv +paste -d "\t" tmp/start tmp/end cut -f1 tmp/start | xargs -I XX -d'\n' -n1 date +%s --date="XX" | @@ -48,9 +47,20 @@ paste -d "\t" tmp/start_unixepoch tmp/end_unixepoch | tee tmp/dateEpoch_final.ts # append the epoch time to the one tsv -cat tmp/dateEpoch_final.tsv | -sed '1s/^/start_unixepoch end_unixepoch @ /' | -tr '@' '\n' | tee tmp/dateEpoch_final.tsv +#cat tmp/dateEpoch_final.tsv | +#sed '1s/^/start_unixepoch end_unixepoch @ /' | +# tr '@' '\n' | tee tmp/dateEpoch_final.tsv + +cp --attributes-only tmp/dateEpoch_final.tsv tmp/dateEpoch_final.tsv.tmp +<tmp/dateEpoch_final.tsv sed '1s/^/start_unixepoch end_unixepoch @ /' | +tr '@' '\n' > tmp/dateEpoch_final.tsv.tmp && +mv tmp/dateEpoch_final.tsv.tmp tmp/dateEpoch_final.tsv +cat tmp/dateEpoch_final.tsv + +cp --attributes-only src/db.tsv tmp/db.tmp +paste -d "\t" src/db.tsv tmp/dateEpoch_final.tsv > tmp/db.tmp && +mv tmp/db.tmp src/db.tsv +cut -f19- src/db.tsv + -paste -d "\t" src/db.tsv tmp/dateEpoch_final.tsv | tee src/db.tsv