I have the following csv file:
hindex
1
2
2
6
3
3
3
2
2
I am trying to read the row and check its value but it gives the following error:
ValueError: invalid literal for int() with base 10: 'hindex'
The code is:
cr = csv.reader(open('C:\\Users\\chatterjees\\Desktop\\data\\topic_hindex.csv', "rb"))
for row in cr:
x=row[0]
if(int(x)<=10):
print x
what’s wrong in my code?
You need to skip row 1. It is trying to parse your column header from the file in to an int, but since it is a char string, it is choking and dying.