Using xlrd, getting list of integers from excel

Viewed 29

In the excel Table I have following entires:

enter image description here

Now I import the entries of M[i][j] as follows:

M = [[0]* n[i] for i in range(nJobs)]
    iter_i = 0
    for i in range(nJobs):
        if i != 0:
            iter_i = iter_i+n[i-1]
        for j in range(n[i]):
            M[i][j] = DataSheet.cell(5 + j + iter_i, 5).value

Each element of M[i][j] is saved as a float, however I need them to be integers or list of integers (for cells with multiple numbers separated by a comma), since those elements are needed for iteration. Is there any way to convert each of the elements of M[i][j] to a list of integers?

1 Answers

Solved as follows:

M = [[0]* n[i] for i in range(nJobs)]
    iter_i = 0
    cellInfo = []
    for i in range(nJobs):
        if i != 0:
            iter_i = iter_i+n[i-1]
        for j in range(n[i]):
            cellInfo = DataSheet.cell(5 + j + iter_i, 5).value
            M[i][j] = [int(y) for y in cellInfo.split(",")]
Related