I am confuse with this one: The program doesn´t return any error when I run it and if I go to the students table the names are there, but check50 says it imports "[]". Am I at least close to make this?
from sys import exit, argv
from cs50 import SQL import csv import cs50
if len(argv) != 2:
print("missing command-line argument")
exit(1)
db = SQL("sqlite:///students.db")
with open("characters.csv", "r") as characters: reader = csv.DictReader(characters)
for row in reader:
name = row["name"]
house = row["house"]
birth = int(row["birth"])
part = name.split()
if len(part) == 2:
first = part[0]
middle = None
last = part[1]
db.execute("INSERT INTO students (first, middle, last, house, birth) VALUES (?, ?, ?, ?, ?)",first, middle, last, house, birth)
elif len(part) == 3:
first = part[0]
middle = part[1]
last = part[2]
db.execute("INSERT INTO students (first, middle, last, house, birth) VALUES (?, ?, ?, ?, ?)",first, middle, last, house, birth)
This is what check 50 says:
Thank you so much for your time!