Generate IDs

By Ben Welsh

Generates unique identifiers for our participants independent of their Github login and email address.


In [10]:
import csv
import hashlib

In [11]:
reader = list(csv.DictReader(open("./output/participants.csv", 'r')))

In [18]:
row_list = []

In [19]:
for row in reader:
    m = hashlib.md5()
    s = "".join([row['name'], row['login'], row['email']])
    m.update(s)
    row['id'] = m.hexdigest()
    row_list.append(row)

In [20]:
row_list[0]


Out[20]:
{'at_san_diego_2016_training': 'False',
 'avatar_url': 'https://avatars.githubusercontent.com/u/856628?v=3',
 'company': 'Washington Post',
 'contributions': '379',
 'country': 'United States of America',
 'email': 'aaron.colby.williams@gmail.com',
 'first_name': 'Aaron ',
 'id': '9c79f1fbdb9ddab50e010722fb091df8',
 'in_california': 'False',
 'in_coalition': 'True',
 'in_usa': 'True',
 'last_name': 'Williams',
 'location': 'Washington, DC',
 'location_x': '-77.0368707',
 'location_y': '38.9071923',
 'login': 'aboutaaron',
 'name': 'Aaron Williams',
 'state': 'DC'}

In [21]:
len(reader)


Out[21]:
167

In [22]:
len(row_list)


Out[22]:
167

In [27]:
fieldnames = [
    'id',
    'name',
    'first_name',
    'last_name',
    'login',
    'email',
    'company',
    'in_coalition',
    'location',
    'state',
    'country',
    'location_x',
    'location_y',
    'in_california',
    'in_usa',
    'contributions',
    'avatar_url',
    'at_san_diego_2016_training'
]

In [28]:
writer = csv.DictWriter(open("./output/participants.csv", 'w'), fieldnames=fieldnames)

In [29]:
writer.writeheader()

In [30]:
writer.writerows(row_list)