I´m trying to transpose a matrix from a csv-file with the following code:
import csv
from itertools import izip
a = izip(*csv.reader(open("TDM.csv", "rb")))
csv.writer(open("output.csv", "wb")).writerows(a)
Unfortunately the following error occurs:
from itertools import izip
ImportError: cannot import name 'izip'
I already looked through the forums but couldn´t find the right answer for me.
I guess you use Python 3.
Use zip()
builtin instead.
In Python 3 there is no itertools.izip()
as the zip()
builtin behaves similarly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With