python AttributeError: ‘_csv.reader’ object has no attribute ‘next’

I want to convert a csv file into sparse format file with (

The CSV file contains 37 attributes + the label (last column). it doesn’t contain header or index. Exp of the 1st row: 63651000000.0,63651000000.0,153.1,0,0,0,0,0,0,5,1,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1

When entring the following command line : python Z.csv data.txt 38 1

I got the following error:

Traceback (most recent call last):
  File "", line 47, in <module>
    headers =
AttributeError: '_csv.reader' object has no attribute 'next'

Do you have any idea about the problem ?

Leave a Comment