Skip to content

Instantly share code, notes, and snippets.

@davedash
Created June 7, 2016 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davedash/506ee4714fa2f1f42ab624d666ad1a21 to your computer and use it in GitHub Desktop.
Save davedash/506ee4714fa2f1f42ab624d666ad1a21 to your computer and use it in GitHub Desktop.
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