xlrd dynamic variables python -


i can make work this:

book = xlrd.open_workbook(path+'infile') sheet = book.sheet_by_index(0) a, b, c, d = ([] in range (4)) = sheet.col_values(0) b = sheet.col_values(1) c = sheet.col_values(2) d = sheet.col_values(3) 

but want make work this:

dyn_var_list = [a, b, c, d] assert(len(sheet.row_values(0))==len(dyn_var_list)) index, col in enumerate(sheet.row_values(0)):     dyn_var_list[index].append(col) 

however, far can 1 value in lists, using code above, due usage of "(0)" after row_values guess, don't know how resolve of yet.

try

for c in range(sheet.ncols):      r in range(sheet.nrows):           dyn_var_list[c].append(sheet.cell(r,c).value) 

here sheet.nrows gives number of rows in sheet.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -