Last active
September 8, 2018 18:27
-
-
Save ap-Codkelden/f16d965d0fc29f062bf99a2b81c382a8 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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import csv | |
with open('data.csv') as f: | |
reader = csv.reader(f, delimiter=';', quotechar='"') | |
rows = [x for x in reader][1:] | |
c = {} | |
for r in rows: | |
if not r[1]: | |
continue | |
kod = r[0] | |
if not kod in c: | |
c[kod] = [] | |
c[kod].append(r[1]) | |
for k in c.keys(): | |
c[k] = ' | '.join(c[k]) | |
with open('data2.csv', 'w') as f: | |
writer = csv.writer(f, delimiter=';', quotechar='"', | |
quoting=csv.QUOTE_MINIMAL) | |
writer.writerow(['tin', 'founders']) | |
writer.writerows(c.items()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment