I’m not sure if I missed something but i’m stuck a this following step:
Here’s my script:
cat games.csv | while IFS="," read YEAR ROUND WINNER OPPONENT WINNER_GOALS OPPONENT_GOALS do if [[ $OPPONENT != "opponent" ]] then #get count to check if name already exists NAME=$($PSQL "SELECT COUNT(team_id) FROM teams WHERE name ='$OPPONENT'") #echo $OPPONENT #echo $NAME if [[ $NAME -eq 0 ]] then INSERT_TEAM_RESULT=$($PSQL "INSERT INTO teams(name) VALUES ('$OPPONENT')") if [[ $INSERT_TEAM_RESULT == "INSERT 0 1" ]] then echo Inserted into team, $OPPONENT fi fi fi done
I might have an Ideia on why is not working. It might be that it’s only inserting 23 rows instead of 24 wich is odd because if you remove all the duplicates from the csv file it only has 23 entries as well.
Is it my fault or there are people that are stuck here as well?
#Edit just a disclaimer about the duplicates, i’m talking about the opponents column on the csv file.