For example, i would like to transform:
Name,Time,Score
Dan,68,20
Suse,42,40
Tracy,50,38
Into:
Name,Dan,Suse,Tracy
Time,68,
If lines is the list of your original text than it should be
for i in range(1,len(lines)):
lines[i] = lines[i].split(',')
new_lines = []
for i in range(len(lines[0])):
new_lines.append("%s,%s,%s" % (lines[0][i], lines[1][i], lines[2][i]))
or use csv Python module - http://docs.python.org/library/csv.html