I have a csv file with this sample data:
in which I am trying to modify django-import-export's before_import function and overwrite the dataset, and in order to do so I need to empty the current dataset and replace it with a new one. Here is how I do it:
def before_import(self, dataset, using_transactions, dry_run, **kwargs):
"""
code to create a new_dataset
"""
print(dataset.headers)
# delete data rows in dataset
del dataset[0:len(dataset)]
# delete headers
for header in dataset.headers:
del dataset[header]
print(dataset)
"""
code to replace dataset with the new_dataset
"""
what the shown code does is delete the dataset's data and its headers. But the print shows not all headers are deleted.
It skips headers being deleted, or more accurately, it alternates in deleting them.
Is there something I'm missing in here?

