This is because of the differences between python 2 and python 3. Use the built-in function next
in python 3. That is, write next(reader)
instead of reader.next()
in line 47. In addition, you should open the file in the text mode. So, change line 47 as i = open( input_file, 'r' )
.