csv dictreader skip lines

Solutions on MaxInterview for csv dictreader skip lines by the best coders in the world

showing results for - "csv dictreader skip lines"
Ariadna
23 Jun 2019
1with open("myfile.csv", encoding='utf8') as fIn:
2	#skip the first 100 rows 
3    for i in range(100):
4		#fIn.next()  # use next for python2
5        fIn.readline() # use readline for python3 
6	
7    #open file at row 100 
8    fieldnames = ["first_name","last_name"]
9    reader = csv.DictReader(fIn,fieldnames=fieldnames)
10	
11    #now loop through file at row 101
12	for row in reader:
13		print(row['name'])