I have a csv file like following
,0,1,2,3,4,5,6,7,8,9,10,11,12
0,7498.0,7499.0,,,,,,,,,,
1,7445.0,7456.0,,,,,,,,,,
2,7412.0,7413.0,7414.0,,,,,,,,,
3,7338.0,7412.0,7413.0,7414.0,,,,,,,,
4,7261.0,7021.0,,,,,,,,,,
I need to get the length of each line like following. How to do this with python?
2
2
3
4
2
This is not going to work since it counts all line splits.
f = open('myfile','r')
lines = f.readlines()
for line in lines:
li = line.split(',')
print len(li)