📜  csv.DictReader 跳过行 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:01.488000             🧑  作者: Mango

代码示例1
with open("myfile.csv", encoding='utf8') as fIn:
    #skip the first 100 rows 
    for i in range(100):
        #fIn.next()  # use next for python2
        fIn.readline() # use readline for python3 
    
    #open file at row 100 
    fieldnames = ["first_name","last_name"]
    reader = csv.DictReader(fIn,fieldnames=fieldnames)
    
    #now loop through file at row 101
    for row in reader:
        print(row['name'])