This PR adds validation when a CSV file contain duplication of headers
For example, give the following CSV file with the contents below:
name, email,age,name
User1,user@test.com,40,User2
In this case the value that is going to be set a property name in a dataclass is User2. It will overwrite the first value User1.
To avoid this problem, and data inconsistency, a validation is performed right when creating a instance of DataclassReader. If there are duplication a ValueError exception will be raised, showing which fields are duplicated.
In addition to the validation, it has been added support for skipping the validation, that is achieved by passing a keyword argument to the DataclassReader, like so:
This PR adds validation when a CSV file contain duplication of headers
For example, give the following CSV file with the contents below:
In this case the value that is going to be set a property
name
in a dataclass isUser2
. It will overwrite the first valueUser1
.To avoid this problem, and data inconsistency, a validation is performed right when creating a instance of
DataclassReader
. If there are duplication aValueError
exception will be raised, showing which fields are duplicated.In addition to the validation, it has been added support for skipping the validation, that is achieved by passing a keyword argument to the
DataclassReader
, like so:This closes the issue: https://github.com/dfurtado/dataclass-csv/issues/10