Summing specific values within an array in python[Solved] -


i trying operations values have added array.

step 1:

loaded xls file xlrd library , created array. http://i.imgur.com/ig6lz3l.png

here code.

import xlrd  datafile = "data.xls" workbook = xlrd.open_workbook(datafile) sheet = workbook.sheet_by_index(0)  data = [[sheet.cell_value(r, col)              col in range(sheet.ncols)]                  r in range(sheet.nrows)] 

i sum values within column print (data[1][1]) print (data[2][1]) print (data[3][1]) print (data[4][1]) print (data[5][1])

summ way (data[i][1]) ??

like summing rows same column,

i have tried sum data[1] sums values same row (like horizontal sum of values...) , trying vertical sum)

>>> data = [[1,2],[3,4],[5,6]] >>> sum(data[i][1] in range(len(data))) 12 # 2 + 4 + 6 >>>  

Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -