Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #56925

Merging xls into a common one

Date 2013-10-16 16:28 -0700
Subject Merging xls into a common one
From John Mathew <john.mathew.python@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1140.1381972578.18130.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

This code works fine when there are xls in which Row has One column, but
not when Row has more column.
The expectation is to merge the different xls into a common one.
Can somebody please help.


import xlwt
import xlrd
import sys
#Create workbook and worksheet

wbk = xlwt.Workbook()
dest_sheet = wbk.add_sheet('Data_1')

for sheet_idx in range(1, 3):
    sheet = xlrd.open_workbook('Data_%d.xls' % sheet_idx).sheet_by_index(0)

    for i in range(5):
        values = sheet.row_values(i)
        for idx, element in enumerate(values):
            dest_sheet.write(i, sheet_idx+idx, element)

wbk.save('DATA.xls')

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Merging xls into a common one John Mathew <john.mathew.python@gmail.com> - 2013-10-16 16:28 -0700

csiph-web