main_11.py 1.0 KB

12345678910111213141516171819202122232425262728
  1. def anonymize_one(self, column, delete: bool, pattern: AnonymizationPattern = None):
  2. if column is None:
  3. return Logger.log_none_type_error('column')
  4. Logger.log_info_table_manipulation_started(self.filename, f'Anonymize One ({column})')
  5. # delete column in every dataset if found
  6. error_count = 0
  7. if delete:
  8. for ds in self.datasets:
  9. out = ds.delete_column(column)
  10. if out < 1:
  11. error_count += 1
  12. self.remove_columnnames([column])
  13. else:
  14. # if column is not deleted: generate a value for column, random or by pattern
  15. if pattern is None:
  16. for ds in self.datasets:
  17. out = ds.set_columnvalue_random(column)
  18. if out < 1:
  19. error_count += 1
  20. else:
  21. for ds in self.datasets:
  22. out = ds.set_columnvalue_by_pattern(column, pattern)
  23. if out < 1:
  24. error_count += 1
  25. Logger.log_info_table_manipulation_finished(error_count)
  26. return error_count