<div dir="ltr">This code works fine when there are xls in which Row has One column, but not when Row has more column. <div>The expectation is to merge the different xls into a common one.</div><div>Can somebody please help.</div>
<div><br></div><div><br></div><div><div>import xlwt</div><div>import xlrd</div><div>import sys</div><div>#Create workbook and worksheet</div><div><br></div><div>wbk = xlwt.Workbook()</div><div>dest_sheet = wbk.add_sheet('Data_1')</div>
<div><br></div><div>for sheet_idx in range(1, 3):</div><div> sheet = xlrd.open_workbook('Data_%d.xls' % sheet_idx).sheet_by_index(0)</div><div><br></div><div> for i in range(5):</div><div> values = sheet.row_values(i)</div>
<div> for idx, element in enumerate(values):</div><div> dest_sheet.write(i, sheet_idx+idx, element)</div><div><br></div><div>wbk.save('DATA.xls')</div></div></div>