import csv
def csv_reader(file, header=False):
with open(file, "r") as f:
reader = csv.reader(f)
if header:
next(reader)
yield from reader
def main():
g = csv_reader("xxx.csv", header=False)
print(next(g)) # => 一行目
if __name__ == '__main__':
main()
yield from reader
は
for row in reader:
yield row
でも実装できます。