without haste but without rest

[python] csv 헤더 패스하기 본문

ProgrammingLanguage/Python

[python] csv 헤더 패스하기

JinungKim 2021. 5. 11. 17:00

이터레이터 next로 한 줄을 넘어간다.

import csv

with open("mycsv.csv", "r") as csvfile:
    csvreader = csv.reader(csvfile)

    # This line skips the first row of the CSV file.
    next(csvreader)

    for row in csvreader:
        # do stuff with rows...

참조

 

Skip the header of a file with Python's CSV reader

next(csvreader) does the trick.

evanhahn.com

 

Comments