import csv tic = time.process_time() # 2000 ~ 5 seconds # 12000 ~ 26 seconds # 30000 ~ 70 seconds numPeople = 1000 outputCsvPath = os.path.join(os.path.dirname(__file__), "../data_1000_samples.csv") K = Keyboard() F = Factory() fieldnames = list(F.getPerson().keys()) # these keys will be considered "important", and reliably typo-free safeKeys = ["ssn", "sex", "bloodType"] typoProbability = 0.025 numPeopleWithTypos = 0 totNumTypos = 0 totYield = 0 with open(outputCsvPath, "w") as csvfile: writer = csv.DictWriter(csvfile, fieldnames=fieldnames) writer.writeheader() for p in F.getPeople(numPeople): totYield += 1