I want to count the total number of columns in a CSV file. Currently i am using python 2.7 and 3.4. Code works perfectly in these versions and when i try to implement the same thing in python 2.4, it is showing as next() is not defined.
Code i am using currently(2.7 and 3.4)
f = open(sys.argv[1],'r')
reader = csv.reader(f,delimiter=d)
num_cols = len(next(reader)) # Read first line and count columns
My strong need is to implement the same in Python 2.4 . Any help would be greatly appreciated.
csvmodule has been in the standard library since 2.3.reader.next()work? Thenextbuiltin is new in Python 2.6.reader.next(). This should have been available in 2.4.