i want to import a csv file to python and convert numbers to int , each row has different number (row 1 has 4 grade and row 2 has 10 grade) when i want to convert number i got bellow error ValueError: invalid literal for int() with base 10: '' please be informed when i enter equal number in each row problem has been solved .
would you please help me.
my code:
import csv
from statistics import mean
with open ('d:\source.csv') as f :
reader=csv.reader(f)
for row in reader:
name=row[0]
these_grades=list()
for grade in row[1:]:
these_grades.append(int(grade))
csv file :
mandana,5,7,3,15
hamid,3,9,4,20,9,1,8,16,0,5,2,4,7,2,1
sina,19,10,19,6,8,14,3
sara,0,5,20,14
soheila,13,2,5,1,3,10,12,4,13,17,7,7
ali,1,9
sarvin,0,16,16,13,19,2,17,8
error:
ValueError: invalid literal for int() with base 10: ''
'', '''', ''occurs? I don't see it. I don't get an error in running the code and can print out these_grades in the for loop.