Adriano10 Adriano10 - 7 months ago 33
Python Question

shell shift in exel using python

i wrote the following python script that reads the contents of "prom output.csv" file" and after does 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())
for r in cr:

with open("sorted output.csv","w") as f:
cr = csv.writer(f,sys.stdout, lineterminator='\n')
od = collections.OrderedDict(sorted(d.items()))
for k,v in od.items():

The output "sorted output.csv" looks like:

enter image description here

My input file: "prom output.csv" looks like:

enter image description here

I want to slightly modify the current output so that it will have the following form:

enter image description here

Any ideas?


Don't use join for your row content; just combine the header w/ the data into a single list: