laradb

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 66242d21cd3932624f960b93ad7e1455f1b586b8
parent daaf56c603788c9cfc2d4fd7fa3ecc1d5312ba51
Auteurice: vi <vi@bb.re>
Date:   Sun,  3 Nov 2024 20:49:24 +0100

Proto frise ok sur bsd

Diffstat:
M.gitignore | 1+
Msrc/frise.sh | 43++++++++++++++++++-------------------------
Msrc/utils/date_epoch.sh | 29++++++++++++++++++++---------
3 files changed, 39 insertions(+), 34 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,5 +1,6 @@ # éviter de push ce qui est généré dans dist *~ +*.orig dist/tableau.html dist/frise.html tmp/* diff --git a/src/frise.sh b/src/frise.sh @@ -3,7 +3,7 @@ # tout passer en unix epoch : # date -j +%s 195509030000 #ccddmmjjHHMM 1955 09 03 00:00 -./src/utils/date_epoch.sh +#./src/utils/date_epoch.sh DIST="dist/" @@ -11,27 +11,29 @@ DB="src/db.tsv" 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=$( sort tmp/end | tail -n1 | grep -o "^.\{4\}" | sed 's/$/ + 1/' | bc ) +min=$( sort tmp/start | head -n1 | grep -o "^.\{4\}") echo "max = $max : min = $min" # max = 2012 : min = 1971 -min_epoch=$( cut -f1 /tmp/dateEpoch_final.tsv | sort -g | head -n1) -max_epoch=$( cut -f2 /tmp/dateEpoch_final.tsv | 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) echo "$min_epoch ; $max_epoch " # 41900400 ; 1304200800 - entree(){ echo "$line" | cut -d" " -f $1 #echo "$line" | tsv-select -f $1 } + + left(){ - echo "( $(entree 1) - $min_epoch)/ $max_epoch * 100" | bc -l + echo "( $(entree 18) - $min_epoch )/ $max_epoch * 100" | bc -l } width(){ - echo "( $(entree 2) - $(entree 1) )/ $max_epoch * 100" | bc -l + echo "( $(entree 19) - $(entree 18) )/ $max_epoch * 100" | bc -l } annee(){ seq $min $max | xargs printf '<td onclick="sortTable(2)" class="annee">%s</td>\n' @@ -73,34 +75,22 @@ $(while IFS= read -r line; do </thead> ENTETE - else cat <<- CORPS <tr> <td class="titre-complet"> $(entree "1"; entree "4"; entree "5" ; entree "6" )</td> - </tr> - -CORPS - - fi - LIGNE=$(($LIGNE + 1)) -done < $DB -) - -$(LIGNE=1; while IFS= read -r line; do - cat <<- GRAPH - <tr> <td class="rectangle"> <div> <div style="left: $(left)% ; width: $(width)%; background-color: grey; height: 1rem; position: relative;"> </div> </div> - </td> - </tr> -GRAPH + </tr> + +CORPS + fi LIGNE=$(($LIGNE + 1)) -done < /tmp/dateEpoch_final.tsv +done < $DB ) </table> @@ -111,4 +101,7 @@ done < /tmp/dateEpoch_final.tsv cp dist/frise.html ~/coloc.bebou.netlib.re/ echo " firefox coloc.bebou.netlib.re/frise.html" +#cp dist/frise.html ~/Downloads/laradb/ +#firefox ~/Downloads/laradb/frise.html + diff --git a/src/utils/date_epoch.sh b/src/utils/date_epoch.sh @@ -24,21 +24,32 @@ s/X.[^#]*/ /g; #delete the zero s/^\([12]...\)0000/\10101/; # 197001010000 @TODO for date after 2000** s/^\([12].....\)00/\101/; # 197009010000 s/#/ #/; # make the comments a new field #| once there was a pipe -s/^0\{8\}/190001010000/; # for NaN gives a date -# for debian date add : -s/0000 / /; # in format YYYYMMDD ' +s/^0\{8\}/190001010000/; # for NaN gives a date' +#cut -f1 | +#xargs -n1 date -j +%s } clean 4 > tmp/start clean 5 > tmp/end paste -d "\t" tmp/start tmp/end | tee tmp/dateEpoch_final.tsv -cut -f1 tmp/start | -xargs -I XX -d'\n' -n1 date +%s --date="XX" | -tee tmp/start_unixepoch -cut -f1 tmp/end | -xargs -I XX -d'\n' -n1 date +%s --date="XX" | -tee tmp/end_unixepoch +cut -f1 tmp/start | +xargs -n1 date -j +%s | tee tmp/start_unixepoch + +cut -f1 tmp/end | +xargs -n1 date -j +%s > tmp/end_unixepoch paste -d "\t" tmp/start_unixepoch tmp/end_unixepoch | tee tmp/dateEpoch_final.tsv +# append the epoch time to the one tsv + +cat tmp/dateEpoch_final.tsv | +sed '1s/^/start_unixepoch end_unixepoch \\/' | +tr '\' '\n' > tmp/dateEpoch_final.tsv + + +paste -d "\t" src/db.tsv tmp/dateEpoch_final.tsv > src/db.tsv + + + +