def load_movies(self, filePath):
"""
Load a csv file into movie objects in the list.
"""
with open(filePath, 'r') as file:
reader = csv.reader(file)
for row in reader:
# convert the years into number
row[1] = int(row[1])
# convert the status into is_watched
if row[3] == "w":
row[3] = True
else:
row[3] = False
# append new movie info
self.movies.append(Movie(*row))
相似问题