只有在 200 到 400 条记录之间,我才尝试读取 CSV 文件。否则我希望它忽略。出于某种奇怪的原因,我的代码从未到达print(row)行
with open(file) as csv_file:
row_count = sum(1 for line in csv_file)
if (row_count>200 and row_count<400):
csv_reader = csv.reader(csv_file, delimiter=',')
for row in csv_reader:
print(row)