def save(self, file_csv): records = csv.reader(file_csv) next(records) # skip the first line for line in records: if len(line) == 7: title = line[0] author_lf = line[2] isbn = line[4] or None isbn13 = line[5] or None yr_published = line[6] or None author = Author.create_from_csv(author_lf) book = Book(title=title, isbn=isbn, isbn13=isbn13, year_published=yr_published) book.save() book.authors = author book.save()
def save(self, file_csv): records = csv.reader(file_csv) next(records) # skip the first line for line in records: if len(line) == 7: title = line[0] author_lf = line[2] isbn = line[4] or None isbn13 = line[5] or None yr_published = line[6] or None author = Author.create_from_csv(author_lf) book = Book(title=title, isbn=isbn, isbn13=isbn13, year_published=yr_published) book.save() book.authors = author book.save()