Skip to content

Instantly share code, notes, and snippets.

@ap-Codkelden
Last active September 8, 2018 18:27
Show Gist options
  • Save ap-Codkelden/f16d965d0fc29f062bf99a2b81c382a8 to your computer and use it in GitHub Desktop.
Save ap-Codkelden/f16d965d0fc29f062bf99a2b81c382a8 to your computer and use it in GitHub Desktop.
#!/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