Skip to content

Instantly share code, notes, and snippets.

@zkan
Last active December 29, 2017 04:42
Show Gist options
  • Save zkan/114b8dd80c9d0d7313a970284f60ca4a to your computer and use it in GitHub Desktop.
Save zkan/114b8dd80c9d0d7313a970284f60ca4a to your computer and use it in GitHub Desktop.
import csv
from faker import Faker
fake = Faker()
with open('transactions.csv', 'r') as file_:
with open('anonymized_transactions.csv', 'w') as new_file:
reader = csv.DictReader(file_)
writer = csv.DictWriter(new_file, fieldnames=reader.fieldnames)
writer.writeheader()
for row in reader:
row['name'] = fake.name()
row['email'] = fake.email()
row['credit_card_number'] = fake.credit_card_number()
writer.writerow(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment