Created
August 14, 2019 21:23
-
-
Save fkchang/3c51edd5ffd2b82eae006ce0eabc4f2e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from collections import defaultdict | |
str = '''company_name,service | |
Johns Refuge,Normal Pickup | |
Johns Refuge,Bulk Pickup | |
Johns Refuge,Tree Removal | |
Bobs Limited,Normal Pickup | |
Bobs Limited,Bulk Pickup | |
''' | |
lines = str.split("\n") | |
data = lines[1:-1] | |
ddict = defaultdict(list) | |
for str in data: | |
company, services = str.split(",") | |
ddict[company].append(services) | |
for company, services in ddict.items(): | |
print(company + ',' + '"' + ','.join(services) + '"') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment