📜  在 python 代码示例中从 csv 读取特定行

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

代码示例1
You could use a list comprehension to filter the file like so:

with open('file.csv') as fd:
    reader=csv.reader(fd)
    interestingrows=[row for idx, row in enumerate(reader) if idx in (28,62)]
# now interestingrows contains the 28th and the 62th row after the header