diff --git a/app/management/commands/import.py b/app/management/commands/import.py index 480a799..aa575eb 100644 --- a/app/management/commands/import.py +++ b/app/management/commands/import.py @@ -370,7 +370,10 @@ class Command(BaseCommand): with open(file_path, 'r', newline='') as csv_file: reader = csv.reader(csv_file, dialect='mydialect') first = True + error_row_count = 0 + total = 0 for row in reader: + total += 1 if first: # Assume the first row to be the header header = row @@ -388,8 +391,10 @@ class Command(BaseCommand): except Range.DoesNotExist as dne: print("this range = %s, mother range --> %s" % (row[0], row[5])) print(str(dne)) + error_row_count += 1 except ValueError as ve: print(str(ve)) + error_row_count += 1 continue _object_dict = {self.cols_to_django_fields.get(key): value.lstrip('"').rstrip('"') for key, value in zip(header, row)} _object_dict = handle_object_dict(_object_dict, model_name) @@ -402,6 +407,7 @@ class Command(BaseCommand): print('----------------') continue print("Done importing %s" % str(_model)) + print("Total rows = %s, error rows = %s" % (total, error_row_count)) def handle_object_dict(object_dict, model_name):