In the excel Table I have following entires:
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?
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(",")]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.