Created
June 7, 2016 22:21
-
-
Save davedash/506ee4714fa2f1f42ab624d666ad1a21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
from collections import defaultdict | |
__author__ = 'davedash' | |
def main(): | |
# Store the most recent/complete data here. | |
companies = defaultdict(lambda: defaultdict(str)) | |
with open('results-download.csv', 'rb') as csvfile: | |
for row in csv.reader(csvfile): | |
if row[0] == 'survey_id': | |
continue | |
company = row[2] | |
mom = row[28] | |
dad = row[31] | |
adopt = row[34] | |
current = companies[company] | |
if mom: | |
current['mom'] = mom | |
if dad: | |
current['dad'] = dad | |
if adopt: | |
current['adopt'] = adopt | |
for company, data in companies.iteritems(): | |
if not data: | |
continue | |
print ', '.join([company, data['mom'], data['dad'], data['adopt']]) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment