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,14 +12,18 @@ 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
|
||||
if [ ! -f ./birds_plus.db ]; then
|
||||
cmd0="CREATE TABLE liste (Francais string, Autres string, Latin string, Anglais string, Ordre string, Famille string, Liens string);"
|
||||
echo "$cmd0" | sqlite3 ./birds_plus.db
|
||||
|
||||
if [ $? -ne 0 ]; then exit 0; fi
|
||||
fi
|
||||
|
||||
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
|
||||
while IFS=';' read -ra array;
|
||||
@@ -31,17 +35,21 @@ if [ -f "$dir"/Oiseaux_europe.csv ]; then
|
||||
aut="${array[1]}"
|
||||
lat="${array[2]}"
|
||||
en="${array[3]}"
|
||||
ln="${array[4]}"
|
||||
or="${array[4]}"
|
||||
fa="${array[5]}"
|
||||
ln="${array[6]}"
|
||||
|
||||
fr=$(echo "$fr" | sed "s/'/''/g")
|
||||
aut=$(echo "$aut" | 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');"
|
||||
echo "$cmd1" | sqlite3 ./birds.db
|
||||
cmd1="INSERT INTO liste (Francais, Autres, Latin, Anglais, Ordre, Famille, Liens) VALUES ('$fr','$aut','$lat','$en','$or','$fa','$ln');"
|
||||
echo "$cmd1" | sqlite3 ./birds_plus.db
|
||||
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
|
||||
echo -e "${red}No .csv file found !${reset}"
|
||||
@@ -50,5 +58,5 @@ fi
|
||||
|
||||
|
||||
query="SELECT * FROM liste;"
|
||||
result=$(sqlite3 ./birds.db "$query")
|
||||
#echo "$result"
|
||||
result=$(sqlite3 ./birds_plus.db "$query")
|
||||
echo "$result"
|
||||
|
||||
Reference in New Issue
Block a user