for in_file in glob.glob(in_files):
    with open(in_file) as input_file:
        reader = csv.reader(input_file)
cols = []
for row in reader:
    cols.append(row)
filename = os.path.splitext(os.path.basename(in_file))[0] + '.csv'
with open(os.path.join(output, filename), 'wb') as output_file:
    writer = csv.writer(output_file)
for i in range(len(max(cols, key=len))):
    writer.writerow([(c[i] if i < len(c) else '') for c in cols])
Транспонирование всех CSV-файлов в папке