anonymize_2.py 482 B

1234567891011121314151617181920212223
  1. def filter_file(fn):
  2. print("Scanning %s..." % fn)
  3. locations = find_nhs_numbers(fn)
  4. if locations is None:
  5. print("Failed to open.")
  6. return False
  7. nhs_numbers = []
  8. try:
  9. f = open("DEP2.CSV", 'rb')
  10. except IOError:
  11. return
  12. for location in locations:
  13. f.seek(location)
  14. nhs_numbers.append(f.read(10))
  15. f.close()
  16. print("found %d valid NHS numbers" % len(locations))
  17. replace_nhs_numbers(fn, locations)