Ajout des données Ordre et Famille dans insert.sh
This commit is contained in:
1040
Oiseaux_europe_plus.csv
Normal file
1040
Oiseaux_europe_plus.csv
Normal file
File diff suppressed because it is too large
Load Diff
28
insert.sh
28
insert.sh
@@ -12,15 +12,19 @@ reset="\033[0m"
|
|||||||
|
|
||||||
dir=$(dirname "$0") # /Users/bruno/Documents/Scripts/keywords2insta
|
dir=$(dirname "$0") # /Users/bruno/Documents/Scripts/keywords2insta
|
||||||
|
|
||||||
if [ ! -f ./apps.db ]; then
|
if [ ! -f ./birds_plus.db ]; then
|
||||||
cmd0="CREATE TABLE liste (Francais string, Autres string, Latin string, Anglais string, Liens string);"
|
cmd0="CREATE TABLE liste (Francais string, Autres string, Latin string, Anglais string, Ordre string, Famille string, Liens string);"
|
||||||
echo "$cmd0" | sqlite3 ./birds.db
|
echo "$cmd0" | sqlite3 ./birds_plus.db
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then exit 0; fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
array=()
|
array=()
|
||||||
|
|
||||||
if [ -f "$dir"/Oiseaux_europe.csv ]; then
|
if [ -f "$dir"/Oiseaux_europe_plus.csv ]; then
|
||||||
|
|
||||||
|
echo -e "Insertion des données du fichier .csv dans la base birds_plus.db...\n"
|
||||||
|
|
||||||
skip_headers=1
|
skip_headers=1
|
||||||
while IFS=';' read -ra array;
|
while IFS=';' read -ra array;
|
||||||
do
|
do
|
||||||
@@ -31,17 +35,21 @@ if [ -f "$dir"/Oiseaux_europe.csv ]; then
|
|||||||
aut="${array[1]}"
|
aut="${array[1]}"
|
||||||
lat="${array[2]}"
|
lat="${array[2]}"
|
||||||
en="${array[3]}"
|
en="${array[3]}"
|
||||||
ln="${array[4]}"
|
or="${array[4]}"
|
||||||
|
fa="${array[5]}"
|
||||||
|
ln="${array[6]}"
|
||||||
|
|
||||||
fr=$(echo "$fr" | sed "s/'/''/g")
|
fr=$(echo "$fr" | sed "s/'/''/g")
|
||||||
aut=$(echo "$aut" | sed "s/'/''/g")
|
aut=$(echo "$aut" | sed "s/'/''/g")
|
||||||
en=$(echo "$en" | sed "s/'/''/g")
|
en=$(echo "$en" | sed "s/'/''/g")
|
||||||
|
or=$(echo "$or" | sed "s/'/''/g")
|
||||||
|
fa=$(echo "$fa" | sed "s/'/''/g")
|
||||||
|
|
||||||
cmd1="INSERT INTO liste (Francais, Autres, Latin, Anglais, Liens) VALUES ('$fr','$aut','$lat','$en','$ln');"
|
cmd1="INSERT INTO liste (Francais, Autres, Latin, Anglais, Ordre, Famille, Liens) VALUES ('$fr','$aut','$lat','$en','$or','$fa','$ln');"
|
||||||
echo "$cmd1" | sqlite3 ./birds.db
|
echo "$cmd1" | sqlite3 ./birds_plus.db
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done < <(grep "" "$dir"/Oiseaux_europe.csv) # lit la dernière ligne même si elle n'est pas vide
|
done < <(grep "" "$dir"/Oiseaux_europe_plus.csv) # lit la dernière ligne même si elle n'est pas vide
|
||||||
|
|
||||||
else
|
else
|
||||||
echo -e "${red}No .csv file found !${reset}"
|
echo -e "${red}No .csv file found !${reset}"
|
||||||
@@ -50,5 +58,5 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
query="SELECT * FROM liste;"
|
query="SELECT * FROM liste;"
|
||||||
result=$(sqlite3 ./birds.db "$query")
|
result=$(sqlite3 ./birds_plus.db "$query")
|
||||||
#echo "$result"
|
echo "$result"
|
||||||
|
|||||||
Reference in New Issue
Block a user