I've been searching all over the interwebs for an answer to this one.
I have found answers pretty similar and close to this one but not similar enough for me to get the job done.
I've been trying to transform and/or re-order a CSV file that has a single value per line into a CSV with multiple values (comma separated) per line.
The input CSV looks something like this:
Here you go,
import csv lines = with open(inputFile,'rb') as f: for line in csv.reader(f): lines.append(line) def groupUp (lines): finalList =  for row in lines: for i,otherRow in enumerate(finalList): if row==otherRow: finalList[i] += row[1:] break else: finalList.append(row) return finalList with open(newFile,'wb') as f: a = csv.writer(f) a.writerows(groupUp(lines))