我需要搜索我的csv文件,如果输入值等于我csv中'Number'字段内的值,则它应该打印整行。
Number, Product, Year
1,JK,2016,
2,TL,2016,
3,HNK,2016,
尝试过此代码:
number = input('Enter SNo to find: ')
reader = csv.reader(open('new.csv','r'))
for row in reader:
if number == row[0]:
print(row)
但是出现错误:
IndexError: list index out of range