tags:

views:

40

answers:

3

b holds the contents of a csv file

i need to go through every row of b; however, since it has a header, i dont want to pay attention to the header. how do i start from the second row?

for row in b (starting from the second row!!):
+1  A: 
b.next()
for row in b:
    # do something with row

But consider using the csv module, especially with DictReader.

Matthew Flaschen
+1  A: 

Easiest way is to use a DictReader. It will consume the first row for you

gnibbler
+2  A: 

Prepend a next(b) (in every recent version of Python; b.next() in older ones) to skip the first row (if b is an iterator; if it is, instead, a list, for row in b[1:]:, of course).

Alex Martelli