-2

I have a list of list with this elements:

listes = [["a","b"],["c","d"],["e","f"]]

I used to this code for writing my csv:

with open("result.csv", "wb") as f:
    writer = csv.writer(f, delimiter=';')
    writer.writerows(listes)

The result:

a;b
c;d
e;f

But i would like:

a;c;d
b;e;f

Thanks

Chattam
  • 1
  • 1

1 Answers1

0

Transpose your list and write to file

with open("result.csv", "wb") as f:
    writer = csv.writer(f, delimiter=';')
    writer.writerows(zip(*listes))
Ashoka Lella
  • 6,631
  • 1
  • 30
  • 39