Python: how do I always start on the second line in csv?

b contains the contents of the csv file

I need to go through each line from b; however, since it has a title, I do not want to pay attention to the title. How to start from the second line?

for row in b (starting from the second row!!): 
+7
python csv
source share
4 answers

Prepare a next(b) (in each latest version of Python; b.next() in older versions) to skip the first line (if b is an iterator, and if it is a list, for row in b[1:]: course )

+12
source share
 b.next() for row in b: # do something with row 

But consider using the csv module, especially with DictReader.

+4
source share

The easiest way is to use DictReader . It will use the first line for you.

+2
source share

You can use this code:

 with open('data.csv', 'a', newline='') as filecsv: datafile = csv.writer(filecsv) datafile.writerows(list) 
0
source share

All Articles