📜  如何在 python 代码示例中读取 csv 文件

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

代码示例6
with open(r'c:\dl\FrameRecentSessions.csv') as csv_file:
    csv_reader = csv.reader(csv_file, delimiter=',')
    line_count = 0
    for row in csv_reader:
        if line_count == 0:
            print(f'Column names are {", ".join(row)}')
            line_count += 1
        else:
            print(f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.')
            line_count += 1
    print(f'Processed {line_count} lines.')