1st commit
This commit is contained in:
1040
Oiseaux_europe.csv
Normal file
1040
Oiseaux_europe.csv
Normal file
File diff suppressed because it is too large
Load Diff
87
bdd.sh
Executable file
87
bdd.sh
Executable file
@@ -0,0 +1,87 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
red="\033[1;31m"
|
||||||
|
greenbold="\033[1;32m"
|
||||||
|
green="\033[0;32m"
|
||||||
|
yellow="\033[0;33m"
|
||||||
|
bold="\033[1m"
|
||||||
|
#bold_under="\033[1;4m"
|
||||||
|
underline="\033[4m"
|
||||||
|
reset="\033[0m"
|
||||||
|
|
||||||
|
search="$1"
|
||||||
|
echo "$search"
|
||||||
|
|
||||||
|
|
||||||
|
req2() {
|
||||||
|
query2="SELECT * FROM liste;"
|
||||||
|
result2=$(sqlite3 ./birds.db "$query2")
|
||||||
|
#echo "$result2"
|
||||||
|
|
||||||
|
array=()
|
||||||
|
while IFS='|' read -ra array;
|
||||||
|
do
|
||||||
|
fr="${array[0]}"
|
||||||
|
aut="${array[1]}"
|
||||||
|
lat="${array[2]}"
|
||||||
|
en="${array[3]}"
|
||||||
|
ln="${array[4]}"
|
||||||
|
[[ $aut != "" ]] && z="($aut)" || z=""
|
||||||
|
|
||||||
|
echo -e "${bold}$fr ${reset} $z"
|
||||||
|
echo "$lat"
|
||||||
|
echo "$en"
|
||||||
|
echo "$ln"
|
||||||
|
echo
|
||||||
|
|
||||||
|
done <<< "$result2"
|
||||||
|
}
|
||||||
|
|
||||||
|
req1() {
|
||||||
|
query1="SELECT * FROM liste WHERE francais LIKE \"%$1%\"";
|
||||||
|
#query2="SELECT * FROM liste WHERE Francais LIKE '%Vautour%'";
|
||||||
|
result1=$(sqlite3 ./birds.db "$query1")
|
||||||
|
echo "$result1"
|
||||||
|
array2=()
|
||||||
|
cmpt=1
|
||||||
|
while IFS='|' read -ra array2;
|
||||||
|
do
|
||||||
|
fr2="${array2[0]}"
|
||||||
|
aut2="${array2[1]}"
|
||||||
|
lat2="${array2[2]}"
|
||||||
|
en2="${array2[3]}"
|
||||||
|
lnk2="${array2[4]}"
|
||||||
|
|
||||||
|
echo ${#fr2}
|
||||||
|
echo ${#aut2}
|
||||||
|
echo ${#lat2}
|
||||||
|
echo ${#en2}
|
||||||
|
echo ${#lnk2}
|
||||||
|
|
||||||
|
#lnk2="https://www.oiseaux.net/oiseaux/vautour.africain.html"
|
||||||
|
#echo "$cmpt $fr2 $aut2 $lat2 $en2 $lnk2"
|
||||||
|
echo "$lnk2"
|
||||||
|
|
||||||
|
echo
|
||||||
|
printf "| %-3s | %-30s | %-30s | %-30s | \n" "$cmpt" "$fr2" "$lat2" "$en2"
|
||||||
|
printf "| %-3s | %-65s | \n" "$cmpt" "${lnk2}"
|
||||||
|
echo
|
||||||
|
#printf "| %-3s | %-55s |\n" "$cmpt" "$lnk"
|
||||||
|
cmpt=$((cmpt+1))
|
||||||
|
done <<< "$result1"
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -f ./birds.db ]; then
|
||||||
|
|
||||||
|
#echo "$result"
|
||||||
|
|
||||||
|
#req2
|
||||||
|
|
||||||
|
echo
|
||||||
|
|
||||||
|
req1 "$1"
|
||||||
|
|
||||||
|
else
|
||||||
|
echo -e "${red}No database found !${reset}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
54
insert.sh
Executable file
54
insert.sh
Executable file
@@ -0,0 +1,54 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
red="\033[1;31m"
|
||||||
|
greenbold="\033[1;32m"
|
||||||
|
green="\033[0;32m"
|
||||||
|
yellow="\033[0;33m"
|
||||||
|
bold="\033[1m"
|
||||||
|
#bold_under="\033[1;4m"
|
||||||
|
underline="\033[4m"
|
||||||
|
reset="\033[0m"
|
||||||
|
|
||||||
|
|
||||||
|
dir=$(dirname "$0") # /Users/bruno/Documents/Scripts/keywords2insta
|
||||||
|
|
||||||
|
if [ ! -f ./apps.db ]; then
|
||||||
|
cmd0="CREATE TABLE liste (Francais string, Autres string, Latin string, Anglais string, Liens string);"
|
||||||
|
echo "$cmd0" | sqlite3 ./birds.db
|
||||||
|
fi
|
||||||
|
|
||||||
|
array=()
|
||||||
|
|
||||||
|
if [ -f "$dir"/Oiseaux_europe.csv ]; then
|
||||||
|
|
||||||
|
skip_headers=1
|
||||||
|
while IFS=';' read -ra array;
|
||||||
|
do
|
||||||
|
if ((skip_headers)); then # Ne pas lire le header
|
||||||
|
((skip_headers--))
|
||||||
|
else
|
||||||
|
fr="${array[0]}"
|
||||||
|
aut="${array[1]}"
|
||||||
|
lat="${array[2]}"
|
||||||
|
en="${array[3]}"
|
||||||
|
ln="${array[4]}"
|
||||||
|
|
||||||
|
fr=$(echo "$fr" | sed "s/'/''/g")
|
||||||
|
aut=$(echo "$aut" | sed "s/'/''/g")
|
||||||
|
en=$(echo "$en" | sed "s/'/''/g")
|
||||||
|
|
||||||
|
cmd1="INSERT INTO liste (Francais, Autres, Latin, Anglais, Liens) VALUES ('$fr','$aut','$lat','$en','$ln');"
|
||||||
|
echo "$cmd1" | sqlite3 ./birds.db
|
||||||
|
fi
|
||||||
|
|
||||||
|
done < <(grep "" "$dir"/Oiseaux_europe.csv) # lit la dernière ligne même si elle n'est pas vide
|
||||||
|
|
||||||
|
else
|
||||||
|
echo -e "${red}No .csv file found !${reset}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
query="SELECT * FROM liste;"
|
||||||
|
result=$(sqlite3 ./birds.db "$query")
|
||||||
|
#echo "$result"
|
||||||
Reference in New Issue
Block a user