I wrote the following python script that reads the contents of "prom output.csv" file, and after some processing it writes the output to the file "sorted output."
import collections
import csv
import sys
with open("prom output.csv","r") as f:
cr = csv.reader(f,delimiter=",")
d=collections.defaultdict(lambda : list())
header=next(cr)
for r in cr:
d[r[0]].append(r[1])
with open("sorted output.csv","w") as f:
cr = csv.writer(f,sys.stdout, lineterminator='\n')
cr.writerow(header)
od = collections.OrderedDict(sorted(d.items()))
for k,v in od.items():
cr.writerow([k,";".join(v)])
The output "sorted output.csv" looks like:
My input file: "prom output.csv" looks like:
I want to slightly modify the current output so that it will have the following form:
Any ideas?


