Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot import name izip [duplicate]

Tags:

python

csv

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.

like image 570
Nils_Denter Avatar asked May 08 '18 18:05

Nils_Denter


1 Answers

I guess you use Python 3.

Use zip() builtin instead.

In Python 3 there is no itertools.izip() as the zip() builtin behaves similarly.

like image 134
abukaj Avatar answered Nov 15 '22 19:11

abukaj