Fixes checking csv length to consider headers

This commit is contained in:
Mouse Reeve 2022-11-25 10:53:42 -08:00
parent 015af2c1e7
commit 304757091e

View file

@ -36,9 +36,10 @@ class Importer:
def create_job(self, user, csv_file, include_reviews, privacy):
"""check over a csv and creates a database entry for the job"""
csv_reader = csv.DictReader(csv_file, delimiter=self.delimiter)
rows = enumerate(list(csv_reader))
if rows:
rows = list(csv_reader)
if len(rows) <= 1:
raise ValueError("CSV file is empty")
rows = enumerate(rows)
job = ImportJob.objects.create(
user=user,